Dockerfile 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. # Install git
  9. RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
  10. # => Building Client
  11. WORKDIR /app/client
  12. RUN yarn install --network-timeout 1000000
  13. RUN yarn build
  14. # => Building Server
  15. WORKDIR /app/server
  16. RUN yarn install --network-timeout 1000000
  17. ENV NODE_ENV production
  18. ENV PORT 80
  19. RUN yarn build
  20. # => Copy to Final container
  21. FROM --platform=$TARGETPLATFORM node:22-slim
  22. WORKDIR /app
  23. COPY --from=builder /app/server/dist /app/dist
  24. COPY --from=builder /app/client/build /app/build
  25. COPY --from=builder /app/server/package.json /app/package.json
  26. COPY --from=builder /app/server/yarn.lock /app/yarn.lock
  27. # Install git
  28. RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
  29. # => Reinstall production dependencies and clean cache
  30. RUN yarn install --production && yarn cache clean
  31. # Make our shell script executable
  32. RUN chmod +x /app/build/env.sh
  33. # Make all files accessible such that the image supports arbitrary user ids
  34. RUN chgrp -R 0 /app && \
  35. chmod -R g=u /app
  36. EXPOSE 3000
  37. # RUN echo -e window.__version="{\"version\":\""$VERSION"\"}" > /app/build/version.js
  38. CMD [ "/bin/bash", "-c", "/app/build/env.sh && yarn start:prod" ]