-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from geoblocks/docker-image
feat: Docker image
- Loading branch information
Showing
10 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules/ | ||
.*-cache/ | ||
.*_cache/ | ||
|
||
dist/ | ||
Dockerfile | ||
.dockerignore | ||
docker-compose.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Choose an app to display. | ||
# If none is selected, the list of apps will be displayed. | ||
# APP_NAME=permits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Publish docker image | ||
|
||
on: | ||
workflow_run: | ||
workflows: ['CI'] | ||
branches: [main] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
env: | ||
DOCKER_REGISTRY: ghcr.io | ||
DOCKER_IMG_NAME: geoblocks/ngv-ui | ||
DOCKER_TAG: latest | ||
|
||
jobs: | ||
build_and_publish: | ||
name: Build and publish | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/login-action@v3 | ||
with: | ||
registry: DOCKER_REGISTRY | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push ngv | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
tags: ${DOCKER_REGISTRY}/${DOCKER_IMG_NAME:${DOCKER_TAG} | ||
- name: Update images sha | ||
run: echo "img_sha=$(docker inspect --format='{{index .RepoDigests 0}}' '${DOCKER_REGISTRY}/${DOCKER_IMG_NAME}:${DOCKER_TAG}' | cut -d':' -f2)" >> $GITHUB_ENV; | ||
|
||
trigger_deploy: | ||
name: Trigger deploy on lab | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
needs: build_and_publish | ||
steps: | ||
- name: Deploy Stage | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GH_PAT_DEPLOY }} | ||
script: | | ||
await github.rest.actions.createWorkflowDispatch({ | ||
owner: 'camptocamp', | ||
repo: 'argocd-gs-plg-apps', | ||
workflow_id: 'update-ngv-image.yaml', | ||
ref: 'main' | ||
inputs: { | ||
environment: prod | ||
img_sha: $img_sha | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: GitHub Container Registry cleanup | ||
|
||
on: | ||
schedule: | ||
- cron: '34 3 8 * *' # Every night the first of the month | ||
|
||
jobs: | ||
cleanup: | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- uses: actions/delete-package-versions@v5 | ||
with: | ||
package-name: 'ngv-ui' | ||
package-type: 'container' | ||
min-versions-to-keep: 5 | ||
delete-only-untagged-versions: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
lib/ | ||
dist/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
# A dockerfile is provided | ||
FROM debian:bookworm-slim AS builder | ||
|
||
# It is based on a stable distro, example debian | ||
|
||
# It produces several images: | ||
# - frontend: contains all apps frontends, served by nginx; | ||
# - backend: contains all apps backends, served by node or deno. | ||
WORKDIR /app | ||
|
||
# An entrypoint allows to select the active app. | ||
RUN apt-get update && apt-get -y install --no-install-recommends \ | ||
npm | ||
|
||
# The images are published to docker hub. | ||
COPY package.json package-lock.json /app/ | ||
RUN npm ci | ||
|
||
COPY . /app/ | ||
RUN npm run build # && npm run doc | ||
|
||
FROM nginxinc/nginx-unprivileged:1.27-bookworm-perl AS server | ||
|
||
LABEL org.opencontainers.image.source="https://github.com/geoblocks/ngv" | ||
|
||
COPY --from=builder /app/dist /usr/share/nginx/html | ||
|
||
# The nginx.conf.template file is used to configure the nginx server. | ||
# In the entrypoint, the environment variables are automatically replaced. | ||
# See docs for more information: https://hub.docker.com/_/nginx | ||
COPY docker/*.conf.template /etc/nginx/templates/ | ||
|
||
# Hooks for the entrypoint | ||
# env files are executed, envsh files are sourced | ||
COPY docker/*.envsh docker/*.sh /docker-entrypoint.d/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
services: | ||
viewer: | ||
build: | ||
context: . | ||
env_file: .env | ||
ports: | ||
- 8080:8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#! /usr/bin/env bash | ||
# This file will be sourced in the container before running the env substitution in the container. | ||
|
||
APP_NAME="${APP_NAME:-all}" | ||
|
||
case "$APP_NAME" in | ||
"") ;; | ||
"/") ;; | ||
"all") ;; | ||
*) export APP_PATH="src/apps/${APP_NAME}" ;; | ||
esac | ||
|
||
entrypoint_log "APP_PATH=$APP_PATH" | ||
|
||
export APP_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Nginx config file | ||
# | ||
|
||
server { | ||
listen 8080; | ||
server_name localhost; | ||
root /usr/share/nginx/html/; | ||
access_log off; | ||
index index.html; | ||
|
||
add_header 'Access-Control-Allow-Origin' '*' always; | ||
expires 4h; | ||
|
||
gzip on; | ||
|
||
gzip_types application/javascript text/css application/json; | ||
|
||
|
||
location / { | ||
# root and alias cannot be use here, because we need to access common files at the root | ||
index $APP_PATH/index.html; | ||
try_files $uri $uri/ =404; | ||
expires -1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters