Skip to content

Commit 42400fa

Browse files
authored
Merge pull request #948 from grasdk/feature/docker-update
Feature/docker update
2 parents c5c7df0 + 74ee2f9 commit 42400fa

File tree

7 files changed

+73
-17
lines changed

7 files changed

+73
-17
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# GitHub recommends pinning actions to a commit SHA.
7+
# To get a newer version, you will need to update the SHA.
8+
# You can also reference a tag or branch, but the action may change without warning.
9+
10+
name: Lint Dockerfiles
11+
12+
on:
13+
push:
14+
branches:
15+
- '**'
16+
17+
jobs:
18+
dockerfile_linting:
19+
name: Dockerfile linting
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Lint Alpine Dockerfile
24+
uses: hadolint/[email protected]
25+
with:
26+
dockerfile: ./docker/alpine/Dockerfile.build
27+
config: ./docker/.config/hadolint.yml
28+
- name: Lint Debian Bookworm Dockerfile
29+
uses: hadolint/[email protected]
30+
with:
31+
dockerfile: ./docker/debian-bookworm/Dockerfile.build
32+
config: ./docker/.config/hadolint.yml
33+
- name: Lint Debian Bullseye Dockerfile
34+
uses: hadolint/[email protected]
35+
with:
36+
dockerfile: ./docker/debian-bullseye/Dockerfile.build
37+
config: ./docker/.config/hadolint.yml
38+
- name: Lint Debian Bullseye Self-contained Dockerfile
39+
uses: hadolint/[email protected]
40+
with:
41+
dockerfile: ./docker/debian-bullseye/selfcontained/Dockerfile
42+
config: ./docker/.config/hadolint.yml

docker/.config/hadolint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ignored:
2+
- DL3008
3+
- DL3018

docker/CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# PiGallery2 Docker Contribution guide (draft)
2+
3+
Remember to update all the Dockerfiles.
4+
5+
## Linting
6+
To quality check your dockerfile changes you can use hadolint:
7+
8+
1. Start the docker daemon if it's not already started: `sudo dockerd`
9+
2. Change dir to the docker folder.
10+
3. Run hadolint on the alpine dockerfile: `docker run --rm -i -v ./.config/hadolint.yml:/.config/hadolint.yaml hadolint/hadolint < ./alpine/Dockerfile.build`
11+
4. Run hadolint on the debian-bookworm dockerfile: `docker run --rm -i -v ./.config/hadolint.yml:/.config/hadolint.yaml hadolint/hadolint < ./debian-bookworm/Dockerfile.build`
12+
5. Run hadolint on the debian-bullseye dockerfile: `docker run --rm -i -v ./.config/hadolint.yml:/.config/hadolint.yaml hadolint/hadolint < ./debian-bullseye/Dockerfile.build`
13+
7. Run hadolint on the debian-bullseye selfcontained dockerfile: `docker run --rm -i -v ./.config/hadolint.yml:/.config/hadolint.yaml hadolint/hadolint < ./debian-bullseye/selfcontained/Dockerfile`
14+
8. Fix errors and warnings or add them to ignore list of the [hadolint configuration file](./.config/hadolint.yml) if there is a good reason for that. Read more [here](https://github.com/hadolint/hadolint).
15+
16+
### Building the docker image locally
17+
TBD

docker/alpine/Dockerfile.build

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#-----------------BUILDER-----------------
22
#-----------------------------------------
33
FROM node:18-alpine3.17 AS builder
4-
RUN apk add --update-cache --repository https://alpine.global.ssl.fastly.net/alpine/v3.17/community/ \
5-
python3 build-base sqlite-dev sqlite-libs imagemagick-dev libraw-dev vips-dev vips-heif vips-magick fftw-dev gcc g++ make libc6-compat && ln -snf /usr/bin/python3 /usr/bin/python
4+
RUN apk add --no-cache --repository https://alpine.global.ssl.fastly.net/alpine/v3.17/community/ \
5+
python3 build-base sqlite-dev sqlite-libs imagemagick-dev libraw-dev vips-dev vips-heif vips-magick fftw-dev gcc g++ make libc6-compat && ln -snf /usr/bin/python3 /usr/bin/python && \
6+
rm /var/cache/apk/*
67
COPY pigallery2-release /app
78
WORKDIR /app
89
RUN npm install --unsafe-perm --fetch-timeout=90000
@@ -26,10 +27,10 @@ ENV NODE_ENV=production \
2627
PI_DOCKER=true
2728

2829
EXPOSE 80
29-
RUN apk add --update-cache --repository https://alpine.global.ssl.fastly.net/alpine/v3.17/community/ \
30-
vips vips-cpp vips-heif vips-magick ffmpeg
30+
RUN apk add --no-cache --repository https://alpine.global.ssl.fastly.net/alpine/v3.17/community/ \
31+
vips vips-cpp vips-heif vips-magick ffmpeg && \
32+
rm /var/cache/apk/*
3133
COPY --from=builder /app /app
32-
VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/tmp"]
3334

3435
# Run build time diagnostics to make sure the app would work after build is finished
3536
RUN ["node", "./src/backend/index", "--expose-gc", "--run-diagnostics", "--config-path=/app/diagnostics-config.json", "--Server-Log-level=silly"]
@@ -40,4 +41,3 @@ HEALTHCHECK --interval=40s --timeout=30s --retries=3 --start-period=60s \
4041
# after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible
4142
# Exec form entrypoint is need otherwise (using shell form) ENV variables are not properly passed down to the app
4243
ENTRYPOINT ["node", "./src/backend/index", "--expose-gc", "--config-path=/app/data/config/config.json"]
43-

docker/debian-bookworm/Dockerfile.build

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#-----------------BUILDER-----------------
22
#-----------------------------------------
33
FROM node:18-bookworm AS builder
4-
RUN apt update && apt install -y --no-install-recommends libvips-dev python3
4+
RUN apt-get update && apt-get install -y --no-install-recommends libvips-dev python3
55
COPY pigallery2-release /app
66
WORKDIR /app
77
RUN npm install --unsafe-perm --fetch-timeout=90000
@@ -30,7 +30,6 @@ RUN apt-get update \
3030
&& apt-get clean -q -y \
3131
&& rm -rf /var/lib/apt/lists/*
3232
COPY --from=builder /app /app
33-
VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/tmp"]
3433

3534
# Run build time diagnostics to make sure the app would work after build is finished
3635
RUN ["node", "./src/backend/index", "--expose-gc", "--run-diagnostics", "--config-path=/app/diagnostics-config.json", "--Server-Log-level=silly"]
@@ -41,4 +40,3 @@ HEALTHCHECK --interval=40s --timeout=30s --retries=3 --start-period=60s \
4140
# after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible
4241
# Exec form entrypoint is need otherwise (using shell form) ENV variables are not properly passed down to the app
4342
ENTRYPOINT ["node", "./src/backend/index", "--expose-gc", "--config-path=/app/data/config/config.json"]
44-

docker/debian-bullseye/Dockerfile.build

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#-----------------BUILDER-----------------
22
#-----------------------------------------
33
FROM node:18-bullseye AS builder
4-
RUN apt update && apt install -y --no-install-recommends libvips-dev python3
4+
RUN apt-get update && apt-get install -y --no-install-recommends libvips-dev python3
55
COPY pigallery2-release /app
66
WORKDIR /app
77
RUN npm install --unsafe-perm --fetch-timeout=90000
@@ -30,7 +30,6 @@ RUN apt-get update \
3030
&& apt-get clean -q -y \
3131
&& rm -rf /var/lib/apt/lists/*
3232
COPY --from=builder /app /app
33-
VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/tmp"]
3433

3534
# Run build time diagnostics to make sure the app would work after build is finished
3635
RUN ["node", "./src/backend/index", "--expose-gc", "--run-diagnostics", "--config-path=/app/diagnostics-config.json", "--Server-Log-level=silly"]
@@ -41,4 +40,3 @@ HEALTHCHECK --interval=40s --timeout=30s --retries=3 --start-period=60s \
4140
# after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible
4241
# Exec form entrypoint is need otherwise (using shell form) ENV variables are not properly passed down to the app
4342
ENTRYPOINT ["node", "./src/backend/index", "--expose-gc", "--config-path=/app/data/config/config.json"]
44-

docker/debian-bullseye/selfcontained/Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ RUN npm install --unsafe-perm \
1010
&& mkdir -p /build/release/data/db \
1111
&& mkdir -p /build/release/data/images \
1212
&& mkdir -p /build/release/data/tmp \
13-
&& npm run create-release \
14-
&& cd /build/release \
15-
&& npm install --unsafe-perm
13+
&& npm run create-release
14+
WORKDIR /build/release
15+
RUN npm install --unsafe-perm
1616

1717
#-----------------MAIN--------------------
1818
#-----------------------------------------
@@ -33,7 +33,6 @@ RUN apt-get update \
3333
&& apt-get clean -q -y \
3434
&& rm -rf /var/lib/apt/lists/*
3535
COPY --from=builder /build/release /app
36-
VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/tmp"]
3736

3837
# Run build time diagnostics to make sure the app would work after build is finished
3938
RUN ["node", "./src/backend/index", "--expose-gc", "--run-diagnostics", "--config-path=/app/diagnostics-config.json"]
@@ -44,4 +43,3 @@ HEALTHCHECK --interval=40s --timeout=30s --retries=3 --start-period=60s \
4443
# after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible
4544
# Exec form entrypoint is need otherwise (using shell form) ENV variables are not properly passed down to the app
4645
ENTRYPOINT ["node", "./src/backend/index", "--expose-gc", "--config-path=/app/data/config/config.json"]
47-

0 commit comments

Comments
 (0)