From 60f7fe858bc495b206d4357cee5f909defbf2255 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Sat, 18 Jan 2025 10:31:13 +0100 Subject: [PATCH] Add dockerfile and build action --- .dockerignore | 4 ++++ .github/workflows/build.yml | 31 +++++++++++++++++++++++++++++++ content/.vitepress/config.js | 8 +------- dockerfile | 13 +++++++++++++ nginx.conf | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/build.yml create mode 100644 dockerfile create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..53ab627 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.vitepress/cache +.git +.DS_Store diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3e6051c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,31 @@ +name: Build + +on: + push: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + lfs: true + + - uses: docker/setup-buildx-action@v1 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: code.smartyellow.net + username: ${{ github.actor }} + password: ${{ secrets.PACKAGE_TOKEN }} + + - name: Build + run: | + docker build . -t code.smartyellow.net/romein/hpg-site + + - name: Push + run: | + docker push code.smartyellow.net/romein/hpg-site diff --git a/content/.vitepress/config.js b/content/.vitepress/config.js index 8ef8759..a473e28 100644 --- a/content/.vitepress/config.js +++ b/content/.vitepress/config.js @@ -64,13 +64,7 @@ export default defineConfig({ text: 'Deze pagina is open source!', }, - lastUpdated: { - text: 'Laatste aanpassing', - formatOptions: { - dateStyle: 'long', - timeStyle: 'short', - }, - }, + lastUpdated: false, docFooter: { prev: 'Vorige', diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..622cdce --- /dev/null +++ b/dockerfile @@ -0,0 +1,13 @@ +FROM node:16-alpine AS build +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +FROM nginx:alpine +COPY nginx.conf /etc/nginx/nginx.conf +WORKDIR /usr/share/nginx/html +COPY --from=build /app/content/.vitepress/dist . + +ENTRYPOINT ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..9d3d438 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,36 @@ +server { + location / { + root /usr/share/nginx/html; + index index.html index.htm; + add_header Cache-Control "public, max-age=0"; + try_files $uri $uri.html $uri/index.html $uri/index.htm $uri/ /index.html /index.htm =404; + } + + location ^~ /immutable/ { + root /usr/share/nginx/html; + expires 1y; + } + + location ^~ /bijlagen/ { + root /usr/share/nginx/html; + expires 1y; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + try_files $uri @redirect_to_index; + internal; + } + + error_page 404 = @handle_404; + location @handle_404 { + root /usr/share/nginx/html; + try_files /404.html @redirect_to_index; + internal; + } + + location @redirect_to_index { + return 302 /; + } +}