Skip to content

Commit 8edfab0

Browse files
authored
Merge pull request #2530 from terrestris/chore/unpriviledged-nginx
chore(docker): use unpriviledged nginx image and add OCI metadata
2 parents 529ea71 + 50d7a17 commit 8edfab0

3 files changed

Lines changed: 39 additions & 10 deletions

File tree

.github/workflows/release_docker.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
tags: |
4343
${{ env.DOCKER_REGISTRY }}/shogun-gis-client:latest
4444
load: true
45+
build-args: |
46+
APP_VERSION=latest
47+
GIT_COMMIT=${{ github.sha }}
4548
4649
- name: Build docker image (version)
4750
if: ${{ inputs.release_is_published }} == 'true'
@@ -51,6 +54,9 @@ jobs:
5154
tags: |
5255
${{ env.DOCKER_REGISTRY }}/shogun-gis-client:${{ inputs.release_version }}
5356
load: true
57+
build-args: |
58+
APP_VERSION=${{ inputs.release_version }}
59+
GIT_COMMIT=${{ github.sha }}
5460
5561
- name: Push docker image to Nexus (latest)
5662
run: |

Dockerfile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,26 @@ COPY . ./
1313

1414
RUN npm run build
1515

16-
FROM nginx:1.29.2-alpine-slim
16+
FROM ghcr.io/nginx/nginx-unprivileged:1.29-alpine-perl AS app
1717

18-
RUN apk update && apk upgrade --no-cache
19-
20-
COPY --from=build /app/build /usr/share/nginx/html
21-
COPY default.conf /etc/nginx/conf.d/default.conf
18+
ENV SHOGUN_GIS_CLIENT_HOST=shogun-gis-client
2219

23-
EXPOSE 80
20+
ARG GIT_COMMIT
21+
ARG APP_VERSION
2422

25-
CMD ["nginx", "-g", "daemon off;"]
23+
COPY --from=build /app/build /usr/share/nginx/html
24+
COPY default.conf /etc/nginx/templates/default.conf.template
25+
26+
# Metadata according to OCI Image Spec
27+
LABEL org.opencontainers.image.authors="info@terrestris.de"
28+
LABEL org.opencontainers.image.created="$(date -u +%Y-%m-%dT%H:%M:%S%z)"
29+
LABEL org.opencontainers.image.source="https://github.com/terrestris/shogun-gis-client"
30+
LABEL org.opencontainers.image.title="The SHOGun WebGIS client"
31+
LABEL org.opencontainers.image.description="Docker image for SHOGun WebGIS client"
32+
LABEL org.opencontainers.image.url=docker-public.terrestris.de/terrestris/shogun-gis-client
33+
LABEL org.opencontainers.image.vendor="terrestris GmbH & Co. KG"
34+
LABEL org.opencontainers.image.licenses="BSD-2-Clause"
35+
LABEL org.opencontainers.image.revision=$GIT_COMMIT
36+
LABEL org.opencontainers.image.version=$APP_VERSION
37+
38+
HEALTHCHECK --timeout=5s --start-period=5s --retries=3 CMD curl -f http://localhost:8080/health || exit 1

default.conf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
server {
2-
listen 80;
3-
listen [::]:80;
4-
server_name localhost;
2+
listen 8080 default_server;
3+
listen [::]:8080 default_server;
4+
5+
server_name ${SHOGUN_GIS_CLIENT_HOST};
6+
7+
# Hide nginx version
8+
server_tokens off;
9+
10+
location /health {
11+
access_log off;
12+
add_header Content-Type text/plain;
13+
return 200 "healthy\n";
14+
}
515

616
location / {
717
root /usr/share/nginx/html;

0 commit comments

Comments
 (0)