2024-08-05 12:06:20 +02:00
|
|
|
FROM node:20-alpine AS javascript-builder
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# It's best to add as few files as possible before running the build commands
|
|
|
|
|
# as they will be re-run everytime one of those files changes.
|
|
|
|
|
#
|
|
|
|
|
# It's possible to run npm install with only the package.json and package-lock.json file.
|
|
|
|
|
|
|
|
|
|
ADD ./client/package.json ./client/package-lock.json ./
|
|
|
|
|
|
|
|
|
|
# Install git and other necessary build tools
|
|
|
|
|
RUN apk add --no-cache git
|
|
|
|
|
|
|
|
|
|
# Clear npm cache, remove existing node_modules, and install dependencies
|
|
|
|
|
RUN npm cache clean --force && \
|
|
|
|
|
rm -rf node_modules && \
|
2024-11-20 18:41:56 +01:00
|
|
|
npm ci
|
2024-08-05 12:06:20 +02:00
|
|
|
|
|
|
|
|
# Explicitly install the correct version of esbuild
|
|
|
|
|
# RUN npm install esbuild@0.21.5
|
|
|
|
|
|
|
|
|
|
ADD ./client/ /app/
|
Enhance Docker Configuration and Health Checks (#761)
* Enhance Docker Configuration and Health Checks
- Added PHP configuration settings in `docker-compose.dev.yml` and `docker-compose.yml` to improve memory management and execution limits, ensuring better performance for PHP applications.
- Introduced health checks for various services including `api`, `api-worker`, `api-scheduler`, `ui`, `redis`, and `db` to ensure service availability and reliability.
- Updated environment variables in `.env.docker` and `client/.env.docker` to include new keys for H-Captcha and reCAPTCHA, enhancing security features.
- Refactored the PHP-FPM entrypoint script to apply PHP configurations dynamically based on environment variables, improving flexibility in deployment.
- Removed outdated PHP configuration files to streamline the Docker setup.
These changes aim to enhance the overall stability, performance, and security of the application in a Dockerized environment.
* Refactor Dockerfile for Improved Build Process
- Changed the Dockerfile to utilize a multi-stage build approach, separating the build and runtime environments for better efficiency.
- Introduced a builder stage using the PHP CLI image to install dependencies and extensions, optimizing the final image size.
- Removed unnecessary installation steps and combined related commands to streamline the Dockerfile, enhancing readability and maintainability.
- Updated the runtime stage to use the PHP FPM Alpine image, ensuring a smaller and more secure production environment.
These changes aim to improve the build process, reduce image size, and enhance the overall performance of the Dockerized application.
2025-05-20 19:20:44 +02:00
|
|
|
|
|
|
|
|
# Optimize memory usage during build
|
|
|
|
|
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
|
|
|
|
# Set production mode to reduce memory usage
|
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
# Disable source maps to reduce memory usage
|
|
|
|
|
ENV GENERATE_SOURCEMAP=false
|
|
|
|
|
# Run the build
|
|
|
|
|
RUN npm run build
|
2024-08-05 12:06:20 +02:00
|
|
|
|
|
|
|
|
FROM node:20-alpine
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
COPY --from=javascript-builder /app/.output/ /app/
|
|
|
|
|
RUN ls /app/
|
|
|
|
|
|
|
|
|
|
CMD [ "node", "./server/index.mjs" ]
|