Dockerfile: make a debugging image

This commit is contained in:
Jesse Chan
2021-01-15 19:42:34 +08:00
parent 05908b14ad
commit f6cd07ed56

View File

@@ -1,4 +1,7 @@
# WARNING:
#
# For development and debugging only. Use Dockerfile.release for production.
#
# This Dockerfile uses contents of current folder which might contain
# secrets, uncommitted changes or other sensitive information. DO NOT
# publish the result image unless it was composed in a clean environment.
@@ -6,37 +9,23 @@
ARG BUILDPLATFORM=amd64
ARG NODE_IMAGE=node:alpine
FROM --platform=$BUILDPLATFORM ${NODE_IMAGE} as nodebuild
FROM --platform=$BUILDPLATFORM ${NODE_IMAGE}
WORKDIR /usr/src/app/
# Copy project files
COPY . ./
# Install build dependencies
# Install dependencies
RUN apk --no-cache add \
python build-base
python build-base mediainfo
# Fetch dependencies from npm
RUN npm ci --no-optional
RUN npm ci --no-optional && npm cache clean --force
# Build package
# Build assets
RUN cp config.cli.js config.js
RUN npm pack
# Now get the clean Node.js image
FROM ${NODE_IMAGE} as flood
# Copy package built
RUN rm -rf /tmp/*
COPY --from=nodebuild /usr/src/app/*.tgz /tmp/
# Install package and then remove caches
RUN npm i -g /tmp/*.tgz && rm -rf /tmp/* /root/*
# Install runtime dependencies
RUN apk --no-cache add \
mediainfo
RUN npm run build-assets
# Create "download" user
RUN adduser -h /home/download -s /sbin/nologin --disabled-password download
@@ -44,8 +33,12 @@ RUN adduser -h /home/download -s /sbin/nologin --disabled-password download
# Run as "download" user
USER download
# Expose port 3000
# Expose port 3000 and 4200
EXPOSE 3000
EXPOSE 4200
# Flood
ENTRYPOINT ["flood", "--host=0.0.0.0"]
# Flood server in development mode
ENTRYPOINT ["npm", "--prefix=/usr/src/app/", "run", "start:development:server", "--", "--host=0.0.0.0"]
# Then, to start a debugging session of frontend:
# docker exec -it ${container_id} npm --prefix=/usr/src/app/ run start:development:client