diff --git a/apps/api/.dockerignore b/apps/api/.dockerignore new file mode 100644 index 0000000..2d6b28a --- /dev/null +++ b/apps/api/.dockerignore @@ -0,0 +1,6 @@ +Dockerfile +.dockerignore +node_modules +npm-debug.log +dist +README.md \ No newline at end of file diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile new file mode 100644 index 0000000..ebd9cb5 --- /dev/null +++ b/apps/api/Dockerfile @@ -0,0 +1,41 @@ +# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker. +# Make sure you update both files! + +FROM node:alpine AS builder +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +RUN apk update +# Set working directory +WORKDIR /app +RUN yarn global add turbo +COPY . . +RUN turbo prune --scope=api --docker + +# Add lockfile and package.json's of isolated subworkspace +FROM node:alpine AS installer +RUN apk add --no-cache libc6-compat +RUN apk update +WORKDIR /app + +# First install dependencies (as they change less often) +COPY .gitignore .gitignore +COPY --from=builder /app/out/json/ . +COPY --from=builder /app/out/yarn.lock ./yarn.lock +RUN yarn install + +# Build the project and its dependencies +COPY --from=builder /app/out/full/ . +COPY turbo.json turbo.json +# COPY .env .env +RUN yarn turbo run build --filter=api... + +FROM node:alpine AS runner +WORKDIR /app + +# Don't run production as root +RUN addgroup --system --gid 1001 nestjs +RUN adduser --system --uid 1001 nestjs +USER nestjs +COPY --from=installer /app . + +CMD node apps/api/dist/main.js \ No newline at end of file diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index a98154e..ae5b74e 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -32,6 +32,7 @@ ARG SENTRY_DSN ARG SENTRYCLI_CDNURL ARG URL_GET_USER_DIRECT ARG URL_CRM_GRAPHQL_DIRECT +ARG URL_CRM_GRAPHQL_PROXY ARG URL_CRM_CREATEKP_DIRECT ARG URL_CRM_DOWNLOADKP_BASE ARG URL_CORE_FINGAP_DIRECT diff --git a/docker-compose.yml b/docker-compose.yml index bcd57c7..a5a885b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: - SENTRYCLI_CDNURL=${SENTRYCLI_CDNURL} - URL_GET_USER_DIRECT=${URL_GET_USER_DIRECT} - URL_CRM_GRAPHQL_DIRECT=${URL_CRM_GRAPHQL_DIRECT} + - URL_CRM_GRAPHQL_PROXY=${URL_CRM_GRAPHQL_PROXY} - URL_CRM_CREATEKP_DIRECT=${URL_CRM_CREATEKP_DIRECT} - URL_CRM_DOWNLOADKP_BASE=${URL_CRM_DOWNLOADKP_BASE} - URL_CORE_FINGAP_DIRECT=${URL_CORE_FINGAP_DIRECT} @@ -23,6 +24,7 @@ services: - SENTRYCLI_CDNURL=${SENTRYCLI_CDNURL} - URL_GET_USER_DIRECT=${URL_GET_USER_DIRECT} - URL_CRM_GRAPHQL_DIRECT=${URL_CRM_GRAPHQL_DIRECT} + - URL_CRM_GRAPHQL_PROXY=${URL_CRM_GRAPHQL_PROXY} - URL_CRM_CREATEKP_DIRECT=${URL_CRM_CREATEKP_DIRECT} - URL_CRM_DOWNLOADKP_BASE=${URL_CRM_DOWNLOADKP_BASE} - URL_CORE_FINGAP_DIRECT=${URL_CORE_FINGAP_DIRECT} @@ -36,6 +38,30 @@ services: - calc_network - auth_network restart: always + depends_on: + - api + + api: + build: + context: . + dockerfile: ./apps/api/Dockerfile + environment: + - REDIS_HOST=redis + - CACHE_TTL=${CACHE_TTL} + - URL_CRM_GRAPHQL_DIRECT=${URL_CRM_GRAPHQL_DIRECT} + restart: always + networks: + - calc_network + depends_on: + - redis + + redis: + image: redis:7-alpine + environment: + ALLOW_EMPTY_PASSWORD: 'yes' + restart: always + networks: + - calc_network networks: calc_network: