diff --git a/apps/backend/Dockerfile b/apps/backend/Dockerfile new file mode 100644 index 0000000..93f1c02 --- /dev/null +++ b/apps/backend/Dockerfile @@ -0,0 +1,21 @@ +# Install dependencies only when needed +FROM docker.io/node:lts-alpine AS deps +# 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 +WORKDIR /usr/src/app +COPY dist/apps/backend/package*.json ./ +RUN npm install --omit=dev + +# Production image, copy all the files and run nest +FROM docker.io/node:lts-alpine AS runner +RUN apk add --no-cache dumb-init +ENV NODE_ENV=production +ENV PORT=3000 +WORKDIR /usr/src/app +COPY --from=deps /usr/src/app/node_modules ./node_modules +COPY --from=deps /usr/src/app/package.json ./package.json +COPY dist/apps/backend . +RUN chown -R node:node . +USER node +EXPOSE 3000 +CMD ["dumb-init", "node", "main.js"] diff --git a/apps/frontend/Dockerfile b/apps/frontend/Dockerfile new file mode 100644 index 0000000..6a0ffc9 --- /dev/null +++ b/apps/frontend/Dockerfile @@ -0,0 +1,27 @@ +# This template uses Automatically Copying Traced Files feature +# so you need to setup your Next Config file to use `output: 'standalone'` +# Please read this for more information https://nextjs.org/docs/pages/api-reference/next-config-js/output + +# Production image, copy all the files and run next +FROM docker.io/node:lts-alpine AS runner +RUN apk add --no-cache dumb-init +ENV NODE_ENV=production +ENV PORT=3000 +WORKDIR /usr/src/app +COPY apps/frontend/next.config.js ./ +COPY apps/frontend/public ./public +COPY apps/frontend/.next/standalone/apps/frontend ./ +COPY apps/frontend/.next/standalone/package.json ./ +COPY apps/frontend/.next/standalone/node_modules ./node_modules +COPY apps/frontend/.next/static ./.next/static +# RUN npm i sharp +RUN chown -R node:node . +USER node +EXPOSE 3000 +# COPY --chown=node:node ./tools/scripts/entrypoints/api.sh /usr/local/bin/docker-entrypoint.sh +# ENTRYPOINT [ "docker-entrypoint.sh" ] +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry. +ENV NEXT_TELEMETRY_DISABLED=1 +CMD ["dumb-init", "node", "server.js"]