Dockerfile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # Remove git
  32. RUN apt-get remove -y git && rm -rf /var/lib/apt/lists/*
  33. # Make our shell script executable
  34. RUN chmod +x /app/build/env.sh
  35. # Make all files accessible such that the image supports arbitrary user ids
  36. RUN chgrp -R 0 /app && \
  37. chmod -R g=u /app
  38. EXPOSE 3000
  39. # RUN echo -e window.__version="{\"version\":\""$VERSION"\"}" > /app/build/version.js
  40. CMD [ "/bin/bash", "-c", "/app/build/env.sh && yarn start:prod" ]