Files
bodyshop-media-server/Dockerfile
2025-11-04 14:43:37 -08:00

52 lines
1.6 KiB
Docker

### ALPINE MULTI-STAGE
# Build stage for libraries
FROM node:22-alpine AS builder
# Install build dependencies including AWS CLI v2
RUN apk add --no-cache bash wget curl unzip gcompat
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm -rf awscliv2.zip aws/
# Node.js application build stage
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install -g typescript
RUN npm install
COPY . .
RUN npm run build
# Final stage
FROM node:22-alpine
# Enable community repository for additional packages
RUN echo "https://dl-cdn.alpinelinux.org/alpine/v$(grep -oE '[0-9]+\.[0-9]+' /etc/alpine-release)/community" >> /etc/apk/repositories
RUN apk update
# Install runtime dependencies including AWS CLI v2
RUN apk add --no-cache bash redis ghostscript graphicsmagick imagemagick libjpeg-turbo libpng libwebp tiff libheif libde265 x265 ffmpeg curl unzip gcompat tzdata
# # Install AWS CLI v2
# RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
# unzip awscliv2.zip && \
# ./aws/install && \
# rm -rf awscliv2.zip aws/ && \
# aws --version
RUN npm install -g pm2
WORKDIR /usr/src/app
# Copy built application from builder
COPY --from=builder /usr/src/app/dist ./dist
COPY ./assets /assets
COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/.env.production ./.env.production
COPY --from=builder /usr/src/app/ecosystem.config.cjs ./ecosystem.config.cjs
EXPOSE 8000
CMD ["sh", "-c", "redis-server --daemonize yes && pm2-runtime ecosystem.config.cjs"]