Dockerfile 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # => Building container
  2. FROM node:18-slim as builder
  3. WORKDIR /app
  4. COPY . .
  5. # => Building Client
  6. WORKDIR /app/client
  7. RUN yarn install
  8. RUN yarn build
  9. # # => Building Server
  10. WORKDIR /app/server
  11. RUN yarn install
  12. ENV NODE_ENV production
  13. ENV PORT 80
  14. RUN yarn build
  15. # => Copy to Final container
  16. FROM node:18-slim
  17. WORKDIR /app
  18. COPY --from=builder /app/server/dist /app/dist
  19. COPY --from=builder /app/client/build /app/build
  20. # COPY --from=builder /app/server/node_modules /app/node_modules
  21. COPY --from=builder /app/server/package.json /app/package.json
  22. COPY --from=builder /app/server/yarn.lock /app/yarn.lock
  23. # => Reinstall production dependencies and clean cache
  24. RUN yarn install --production && yarn cache clean
  25. # Make our shell script executable
  26. RUN chmod +x /app/build/env.sh
  27. # Make all files accessible such that the image supports arbitrary user ids
  28. RUN chgrp -R 0 /app && \
  29. chmod -R g=u /app
  30. EXPOSE 3000
  31. # RUN echo -e window.__version="{\"version\":\""$VERSION"\"}" > /app/build/version.js
  32. CMD [ "/bin/bash", "-c", "/app/build/env.sh && yarn start:prod" ]