59 lines
1.2 KiB
Docker
59 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1.4
|
|
|
|
# Use Alpine for smaller size and faster package manager
|
|
FROM node:lts-alpine AS development
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies using apk (much faster than apt)
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add --update --no-cache \
|
|
vips-dev \
|
|
python3 \
|
|
make \
|
|
g++
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Install npm dependencies with cache
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci --legacy-peer-deps --ignore-scripts
|
|
|
|
# Install sharp
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm install --platform=linux --arch=x64 sharp
|
|
|
|
COPY . .
|
|
|
|
ENV CI=true
|
|
ENV PORT=3000
|
|
|
|
CMD [ "npm", "start" ]
|
|
|
|
# Build stage
|
|
FROM development AS build
|
|
RUN npm run build
|
|
|
|
# Development with tools
|
|
FROM development as dev-envs
|
|
|
|
RUN --mount=type=cache,target=/var/cache/apk \
|
|
apk add --no-cache git
|
|
|
|
RUN adduser -D -s /bin/sh vscode && \
|
|
addgroup docker && \
|
|
addgroup vscode docker
|
|
|
|
COPY --from=gloursdocker/docker / /
|
|
CMD [ "npm", "start" ]
|
|
|
|
# Production
|
|
FROM nginx:alpine AS production
|
|
|
|
COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
|
WORKDIR /usr/share/nginx/html
|
|
RUN rm -rf ./*
|
|
COPY --from=build /app/build .
|
|
|
|
ENTRYPOINT ["nginx", "-g", "daemon off;"] |