37 lines
1.0 KiB
Docker
37 lines
1.0 KiB
Docker
# 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
|
|
USER app
|
|
|
|
# Set up the frontend environment
|
|
WORKDIR /app/frontend
|
|
COPY --chown=app:app ./frontend/package*.json ./
|
|
RUN ln -s /app/frontend/src/types /app/shared/types \
|
|
&& npm install --legacy-peer-deps --unsafe-perm
|
|
|
|
# Set up the backend environment
|
|
WORKDIR /app/backend
|
|
COPY --chown=app:app ./backend/package*.json ./
|
|
RUN npm install --legacy-peer-deps --unsafe-perm
|
|
|
|
# Copy the remaining application files
|
|
WORKDIR /app
|
|
COPY --chown=app:app . .
|
|
RUN chown -R app:app /app
|
|
RUN chmod -R 777 /app/backend/upload
|
|
|
|
|
|
# Expose ports for frontend and backend applications
|
|
EXPOSE 3000
|
|
EXPOSE 3001
|
|
|
|
# Start the application
|
|
CMD ["sh", "./bin/start-dev.sh"]
|