docker: add api & redis
This commit is contained in:
parent
d7ba323355
commit
60f4069aea
6
apps/api/.dockerignore
Normal file
6
apps/api/.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
node_modules
|
||||
npm-debug.log
|
||||
dist
|
||||
README.md
|
||||
41
apps/api/Dockerfile
Normal file
41
apps/api/Dockerfile
Normal file
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user