Dockerfile 1.2 KB

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