29845/Dockerfile.dev
2025-03-12 23:00:36 +00:00

64 lines
1.8 KiB
Docker

# Base image for Node.js dependencies
FROM node:20.15.1-alpine AS frontend-deps
RUN apk add --no-cache git
WORKDIR /app/frontend
COPY frontend/package.json frontend/yarn.lock ./
RUN yarn install --pure-lockfile
FROM node:20.15.1-alpine AS backend-deps
RUN apk add --no-cache git
WORKDIR /app/backend
COPY backend/package.json backend/yarn.lock ./
RUN yarn install --pure-lockfile
FROM node:20.15.1-alpine AS app-shell-deps
RUN apk add --no-cache git
WORKDIR /app/app-shell
COPY app-shell/package.json app-shell/yarn.lock ./
RUN yarn install --pure-lockfile
# Nginx setup and application build
FROM node:20.15.1-alpine AS build
RUN apk add --no-cache git nginx
RUN yarn global add concurrently
# Make sure to add yarn global bin to PATH
ENV PATH /root/.yarn/bin:/root/.config/yarn/global/node_modules/.bin:$PATH
# Copy dependencies
WORKDIR /app
COPY --from=frontend-deps /app/frontend /app/frontend
COPY --from=backend-deps /app/backend /app/backend
COPY --from=app-shell-deps /app/app-shell /app/app-shell
COPY frontend /app/frontend
COPY backend /app/backend
COPY app-shell /app/app-shell
COPY docker /app/docker
# Copy Nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Copy all files from root to /app
COPY . /app
# Expose the port the app runs on
EXPOSE 8080
ENV NODE_ENV=dev_stage
ENV FRONT_PORT=3001
ENV APP_SHELL_PORT=4000
# Start app_shell
CMD ["sh", "-c", "\
concurrently --kill-others-on-fail \
\"yarn --cwd /app/frontend dev\" \
\"yarn --cwd /app/backend start\" \
\"sleep 10 && nginx -g 'daemon off;'\" & \
CONC_PID=$! && \
echo 'Waiting for frontend (port ${FRONT_PORT}) to be available...' && \
while ! nc -z localhost ${FRONT_PORT}; do \
sleep 2; \
done && \
echo 'Frontend is up. Starting app_shell for Git check...' && \
yarn --cwd /app/app-shell start && \
wait $CONC_PID"]