-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
444 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
dist | ||
.env | ||
.env | ||
DB_MIGRATION_HASH_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ data/ | |
bin/ | ||
coverage/ | ||
.idea/ | ||
migrations/tenants-migration-hash.txt | ||
DB_MIGRATION_HASH_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,40 @@ | ||
FROM node:18-alpine | ||
# Base stage for shared environment setup | ||
FROM node:18-alpine as base | ||
RUN apk add --no-cache g++ make python3 | ||
WORKDIR /app | ||
COPY package.json package-lock.json ./ | ||
RUN npm ci --production | ||
|
||
FROM node:18-alpine | ||
RUN apk add --no-cache g++ make python3 | ||
WORKDIR /app | ||
COPY . . | ||
# Dependencies stage - install and cache all dependencies | ||
FROM base as dependencies | ||
RUN npm ci | ||
# Cache the installed node_modules for later stages | ||
RUN cp -R node_modules /node_modules_cache | ||
|
||
# Build stage - use cached node_modules for building the application | ||
FROM base as build | ||
COPY --from=dependencies /node_modules_cache ./node_modules | ||
COPY . . | ||
RUN npm run build | ||
|
||
FROM node:18-alpine | ||
# Production dependencies stage - use npm cache to install only production dependencies | ||
FROM base as production-deps | ||
COPY --from=dependencies /node_modules_cache ./node_modules | ||
RUN npm ci --production | ||
|
||
# Final stage - for the production build | ||
FROM base as final | ||
ARG VERSION | ||
ENV VERSION=$VERSION | ||
WORKDIR /app | ||
COPY migrations migrations | ||
COPY ecosystem.config.js package.json ./ | ||
COPY --from=0 /app/node_modules node_modules | ||
COPY --from=1 /app/dist dist | ||
|
||
# Copy production node_modules from the production dependencies stage | ||
COPY --from=production-deps /app/node_modules node_modules | ||
# Copy build artifacts from the build stage | ||
COPY --from=build /app/dist dist | ||
COPY ./docker-entrypoint.sh . | ||
|
||
RUN node dist/scripts/migration-hash.js | ||
|
||
EXPOSE 5000 | ||
ENTRYPOINT ["docker-entrypoint.sh"] | ||
CMD ["node", "dist/server.js"] | ||
ENTRYPOINT ["./docker-entrypoint.sh"] | ||
CMD ["node", "dist/server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,11 @@ | ||
#!/usr/bin/env bash | ||
#!/usr/bin/env sh | ||
set -Eeuo pipefail | ||
|
||
# usage: file_env VAR [DEFAULT] | ||
# ie: file_env 'XYZ_DB_PASSWORD' 'example' | ||
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of | ||
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) | ||
file_env() { | ||
local var="$1" | ||
local fileVar="${var}_FILE" | ||
local def="${2:-}" | ||
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then | ||
echo >&2 "error: both $var and $fileVar are set (but are exclusive)" | ||
exit 1 | ||
fi | ||
local val="$def" | ||
if [ "${!var:-}" ]; then | ||
val="${!var}" | ||
elif [ "${!fileVar:-}" ]; then | ||
val="$(< "${!fileVar}")" | ||
fi | ||
export "$var"="$val" | ||
unset "$fileVar" | ||
} | ||
|
||
# load secrets either from environment variables or files | ||
file_env 'ANON_KEY' | ||
file_env 'SERVICE_KEY' | ||
file_env 'PGRST_JWT_SECRET' | ||
file_env 'DATABASE_URL' | ||
file_env 'MULTITENANT_DATABASE_URL' | ||
file_env 'LOGFLARE_API_KEY' | ||
file_env 'LOGFLARE_SOURCE_TOKEN' | ||
# Check if the DB_MIGRATION_HASH_FILE exists and is not empty | ||
if [ -s DB_MIGRATION_HASH_FILE ]; then | ||
export DB_MIGRATION_HASH=$(cat DB_MIGRATION_HASH_FILE) | ||
fi | ||
|
||
exec "${@}" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export { default as bucket } from './bucket' | ||
export { default as object } from './object' | ||
export { default as render } from './render' | ||
export { default as tenant } from './tenant' | ||
export { default as multiPart } from './tus' | ||
export { default as healthcheck } from './health' | ||
export * from './tenant' |
Oops, something went wrong.