Skip to content

Commit 859c4c1

Browse files
committed
Trying to remerge from previous to keep a similar mindset (build and main) #1122
1 parent 3b87ed8 commit 859c4c1

File tree

1 file changed

+40
-30
lines changed

1 file changed

+40
-30
lines changed

docker/alpine/Dockerfile.build

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
2-
# ============================================================
3-
# Stage 1: Build libvips with full colourspace + loaders
4-
# ============================================================
5-
FROM alpine:3.22 AS vips-build
1+
#-----------------BUILDER-----------------
2+
#-----------------------------------------
3+
FROM node:22-alpine3.22 AS builder
64

75
ARG VIPS_VERSION=8.15.2
86

@@ -46,47 +44,59 @@ RUN wget https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/v
4644
make install && \
4745
ldconfig || true
4846

49-
# ============================================================
50-
# Stage 2: Runtime image
51-
# ============================================================
52-
FROM node:20-alpine3.22 AS runtime
53-
54-
RUN apk add --no-cache \
55-
libjpeg-turbo libpng libwebp tiff lcms2 libexif libimagequant \
56-
orc glib expat zlib ffmpeg
57-
47+
COPY pigallery2-release /app
5848
WORKDIR /app
59-
60-
# Bring in custom libvips
61-
COPY --from=vips-build /usr/lib /usr/lib
62-
COPY --from=vips-build /usr/bin/vips* /usr/bin/
63-
64-
# Copy prebuilt PiGallery2 release
65-
COPY pigallery2-release/ /app/
66-
67-
# Install production dependencies
68-
RUN npm install --omit=dev && npm cache clean --force
49+
RUN npm install --no-package-lock --save-dev node-addon-api@8.5.0 node-gyp@11.5.0 && \
50+
npm prune --production && \
51+
npm cache clean --force
6952

7053
# Create data directories
7154
RUN mkdir -p /app/data/config \
7255
/app/data/db \
7356
/app/data/images \
7457
/app/data/tmp
7558

59+
60+
#-----------------MAIN--------------------
61+
#-----------------------------------------
62+
FROM node:22-alpine3.22 AS main
63+
WORKDIR /app
64+
65+
66+
67+
7668
ENV NODE_ENV=production \
77-
default-Database-dbFolder=/app/data/db \
78-
default-Media-folder=/app/data/images \
79-
default-Media-tempFolder=/app/data/tmp \
80-
default-Extensions-folder=/app/data/config/extensions \
81-
PI_DOCKER=true
69+
# overrides only the default value of the settings (the actual value can be overwritten through config.json)
70+
default-Database-dbFolder=/app/data/db \
71+
default-Media-folder=/app/data/images \
72+
default-Media-tempFolder=/app/data/tmp \
73+
default-Extensions-folder=/app/data/config/extensions \
74+
# flagging dockerized environment
75+
PI_DOCKER=true
8276

8377
EXPOSE 80
78+
ARG TARGETARCH
79+
RUN apk add --no-cache \
80+
libjpeg-turbo libpng libwebp tiff lcms2 libexif libimagequant \
81+
orc glib expat zlib ffmpeg \
82+
&& if [ "$TARGETARCH" = "amd64" ]; then \
83+
echo "Building for amd64, adding intel-media-driver" && \
84+
apk add --no-cache intel-media-driver; \
85+
fi \
86+
&& rm -rf /var/cache/apk/*
87+
88+
89+
COPY --from=builder /usr/lib /usr/lib
90+
COPY --from=builder /usr/bin/vips* /usr/bin/
91+
COPY --from=builder /app /app
8492

85-
# Diagnostics
93+
# Run build time diagnostics to make sure the app would work after build is finished
8694
RUN ["node", "--expose-gc", "./src/backend/index", "--run-diagnostics", "--config-path=/app/diagnostics-config.json", "--Server-Log-level=silly"]
8795

8896
HEALTHCHECK --interval=40s --timeout=30s --retries=3 --start-period=60s \
8997
CMD wget --quiet --tries=1 --no-check-certificate --spider \
9098
http://127.0.0.1:80/heartbeat || exit 1
9199

100+
# after a extensive job (like video converting), pigallery calls gc, to clean up everything as fast as possible
101+
# Exec form entrypoint is need otherwise (using shell form) ENV variables are not properly passed down to the app
92102
ENTRYPOINT ["node", "--expose-gc", "./src/backend/index", "--config-path=/app/data/config/config.json"]

0 commit comments

Comments
 (0)