From 5e3595f97f14e57e1fdee62ddbb7ddc68df89dd4 Mon Sep 17 00:00:00 2001 From: Ryjek Date: Tue, 14 Jul 2026 15:01:23 +0200 Subject: [PATCH] add docker for release; add cicdg --- .dockerignore | 4 +++ .github/workflows/docker.yml | 48 ++++++++++++++++++++++++++++++++++++ services/Dockerfile | 15 +++++++++++ services/nginx.conf | 22 +++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker.yml create mode 100644 services/Dockerfile create mode 100644 services/nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0140c3b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +dist +node_modules +package-lock.json +README.md \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..238328b --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,48 @@ +name: Build and Deploy Docker + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: git.rhost.ovh + username: ${{ github.actor }} + password: ${{ secrets.TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./services/Dockerfile + push: true + tags: git.rhost.ovh/${{ github.repository }}:latest + deploy: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.SERVER_HOST }} + port: ${{ secrets.SERVER_PORT }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SERVER_SSH_KEY }} + script: | + cd /home/ryjek/docker/sprawozdania + docker compose pull frontend + docker compose up -d frontend \ No newline at end of file diff --git a/services/Dockerfile b/services/Dockerfile new file mode 100644 index 0000000..98a2a8c --- /dev/null +++ b/services/Dockerfile @@ -0,0 +1,15 @@ +FROM node:22.15 as build +RUN mkdir /public + +WORKDIR /public +COPY . . + +RUN npm install +RUN npm run build + +FROM nginx:alpine + +COPY --from=build /public/dist /usr/share/nginx/html +COPY ./services/nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 \ No newline at end of file diff --git a/services/nginx.conf b/services/nginx.conf new file mode 100644 index 0000000..8422b8d --- /dev/null +++ b/services/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location /api/ { + proxy_pass http://backend/; + + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + + location / { + try_files $uri $uri/ /index.html; + } +} \ No newline at end of file