Dockerfile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 and dependencies in a single layer, then remove git
  28. RUN apt-get update && \
  29. apt-get install -y git && \
  30. yarn install --production && \
  31. yarn cache clean && \
  32. apt-get remove -y git && \
  33. apt-get clean && \
  34. rm -rf /var/lib/apt/lists/*
  35. # Make our shell script executable and set permissions
  36. RUN chmod +x /app/build/env.sh && \
  37. chgrp -R 0 /app && \
  38. chmod -R g=u /app
  39. EXPOSE 3000
  40. # RUN echo -e window.__version="{\"version\":\""$VERSION"\"}" > /app/build/version.js
  41. CMD [ "/bin/bash", "-c", "/app/build/env.sh && yarn start:prod" ]