|
|
|
|
|
|
|
ARG INCLUDE_DB=false |
|
|
|
|
|
FROM node:20 as builder-production |
|
|
|
WORKDIR /app |
|
|
|
COPY --link --chown=1000 package-lock.json package.json ./ |
|
RUN --mount=type=cache,target=/app/.npm \ |
|
npm set cache /app/.npm && \ |
|
npm ci --omit=dev |
|
|
|
FROM builder-production as builder |
|
|
|
ARG APP_BASE= |
|
ARG PUBLIC_APP_COLOR=blue |
|
|
|
RUN --mount=type=cache,target=/app/.npm \ |
|
npm set cache /app/.npm && \ |
|
npm ci |
|
|
|
COPY --link --chown=1000 . . |
|
|
|
RUN npm run build |
|
|
|
|
|
FROM mongo:latest as mongo |
|
|
|
|
|
FROM node:20-slim as local_db_false |
|
|
|
|
|
FROM node:20-slim as local_db_true |
|
|
|
RUN apt-get update |
|
RUN apt-get install gnupg curl -y |
|
|
|
COPY --from=mongo /usr/bin/mongo* /usr/bin/ |
|
|
|
ENV MONGODB_URL=mongodb://localhost:27017 |
|
RUN mkdir -p /data/db |
|
RUN chown -R 1000:1000 /data/db |
|
|
|
|
|
FROM local_db_${INCLUDE_DB} as final |
|
|
|
|
|
ARG INCLUDE_DB=false |
|
ENV INCLUDE_DB=${INCLUDE_DB} |
|
|
|
|
|
ARG APP_BASE= |
|
|
|
ARG PUBLIC_APP_COLOR=blue |
|
|
|
|
|
|
|
RUN npm install -g dotenv-cli |
|
|
|
|
|
RUN userdel -r node |
|
RUN useradd -m -u 1000 user |
|
USER user |
|
|
|
ENV HOME=/home/user \ |
|
PATH=/home/user/.local/bin:$PATH |
|
|
|
WORKDIR /app |
|
|
|
|
|
RUN touch /app/.env.local |
|
|
|
|
|
COPY --chown=1000 package.json /app/package.json |
|
COPY --chown=1000 .env /app/.env |
|
COPY --chown=1000 entrypoint.sh /app/entrypoint.sh |
|
COPY --chown=1000 gcp-*.json /app/ |
|
|
|
|
|
COPY --from=builder --chown=1000 /app/build /app/build |
|
COPY --from=builder --chown=1000 /app/node_modules /app/node_modules |
|
|
|
RUN chmod +x /app/entrypoint.sh |
|
|
|
CMD ["/bin/bash", "-c", "/app/entrypoint.sh"] |
|
|