2025-03-22 13:42:37 +00:00
|
|
|
# Use Node.js 18 with Alpine Linux as the base image
|
|
|
|
FROM node:18-alpine
|
|
|
|
RUN apk add --no-cache python3 make g++ && ln -sf python3 /usr/bin/python
|
|
|
|
|
|
|
|
# Create a new user and group for better security
|
|
|
|
RUN addgroup app && adduser -SG app app \
|
|
|
|
&& mkdir -p /app/frontend /app/backend /app/shared \
|
|
|
|
&& chown -R app:app /app
|
|
|
|
|
|
|
|
# Switch to the new user
|
2021-12-21 17:38:39 +00:00
|
|
|
USER app
|
|
|
|
|
2025-03-22 13:42:37 +00:00
|
|
|
# Set up the frontend environment
|
2022-12-07 20:05:12 +00:00
|
|
|
WORKDIR /app/frontend
|
|
|
|
COPY --chown=app:app ./frontend/package*.json ./
|
2025-03-22 13:42:37 +00:00
|
|
|
RUN ln -s /app/frontend/src/types /app/shared/types \
|
|
|
|
&& npm install --legacy-peer-deps --unsafe-perm
|
2022-12-07 20:05:12 +00:00
|
|
|
|
2025-03-22 13:42:37 +00:00
|
|
|
# Set up the backend environment
|
2022-12-07 20:05:12 +00:00
|
|
|
WORKDIR /app/backend
|
|
|
|
COPY --chown=app:app ./backend/package*.json ./
|
2025-03-22 13:42:37 +00:00
|
|
|
RUN npm install --legacy-peer-deps --unsafe-perm
|
2021-12-21 17:38:39 +00:00
|
|
|
|
2025-03-22 13:42:37 +00:00
|
|
|
# Copy the remaining application files
|
2021-12-21 17:38:39 +00:00
|
|
|
WORKDIR /app
|
2025-03-22 15:05:08 +00:00
|
|
|
# After creating directories
|
|
|
|
RUN mkdir -p /app/backend/assets/upload /app/backend/logs && \
|
|
|
|
chown -R app:app /app/backend/assets /app/backend/logs && \
|
|
|
|
chmod -R 755 /app/backend/assets /app/backend/logs
|
|
|
|
RUN chown -R app:app /app/backend/assets/upload
|
2021-12-21 17:38:39 +00:00
|
|
|
COPY --chown=app:app . .
|
2025-03-22 13:42:37 +00:00
|
|
|
RUN chown -R app:app /app
|
|
|
|
|
|
|
|
# Expose ports for frontend and backend applications
|
2021-12-21 17:38:39 +00:00
|
|
|
EXPOSE 3000
|
2025-03-22 13:42:37 +00:00
|
|
|
EXPOSE 3001
|
|
|
|
|
|
|
|
# Start the application
|
|
|
|
CMD ["sh", "./bin/start-dev.sh"]
|