added modifications to build Docker image in Gitea Runners

This commit is contained in:
Frédérick Pruneau 2026-02-24 09:13:19 -05:00
parent 58db6f7ac4
commit b353db518c
Signed by: fred
SSH Key Fingerprint: SHA256:NE8ZTR2qtoXf35Rq2m2y6PQA0sIUFPVTEIsGwG9FsXk
2 changed files with 37 additions and 45 deletions

View File

@ -36,13 +36,13 @@ jobs:
- name: Run linter - name: Run linter
run: npm run lint run: npm run lint
- name: Notify Google Chat # - name: Notify Google Chat
if: ${{ failure() }} # Use always to ensure that the notification is also send on failure of former steps # if: ${{ failure() }} # Use always to ensure that the notification is also send on failure of former steps
uses: SimonScholz/google-chat-action@3b3519e5102dba8aa5046fd711c4b553586409bb # v1.1.0 # uses: SimonScholz/google-chat-action@3b3519e5102dba8aa5046fd711c4b553586409bb # v1.1.0
with: # with:
webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK }}' # webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK }}'
jobStatus: ${{ job.status }} # jobStatus: ${{ job.status }}
title: Lint failed # title: Lint failed
test: test:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
@ -62,13 +62,13 @@ jobs:
- name: Run tests - name: Run tests
run: npm test run: npm test
- name: Notify Google Chat # - name: Notify Google Chat
if: ${{ failure() }} # Use always to ensure that the notification is also send on failure of former steps # if: ${{ failure() }} # Use always to ensure that the notification is also send on failure of former steps
uses: SimonScholz/google-chat-action@3b3519e5102dba8aa5046fd711c4b553586409bb # v1.1.0 # uses: SimonScholz/google-chat-action@3b3519e5102dba8aa5046fd711c4b553586409bb # v1.1.0
with: # with:
webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK }}' # webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK }}'
jobStatus: ${{ job.status }} # jobStatus: ${{ job.status }}
title: Test failed # title: Test failed
build: build:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
@ -99,27 +99,28 @@ jobs:
name: source name: source
path: src path: src
retention-days: 1 retention-days: 1
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: Dockerfile name: Dockerfile
path: Dockerfile path: Dockerfile
retention-days: 1 retention-days: 1
- name: Notify Google Chat # - name: Notify Google Chat
if: ${{ failure() }} # Use always to ensure that the notification is also send on failure of former steps # if: ${{ failure() }} # Use always to ensure that the notification is also send on failure of former steps
uses: SimonScholz/google-chat-action@3b3519e5102dba8aa5046fd711c4b553586409bb # v1.1.0 # uses: SimonScholz/google-chat-action@3b3519e5102dba8aa5046fd711c4b553586409bb # v1.1.0
with: # with:
webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK }}' # webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK }}'
jobStatus: ${{ job.status }} # jobStatus: ${{ job.status }}
title: Build failed # title: Build failed
#- name: deploy
# if: ${{ success() }}
# run: docker build -t targo_frontend .
deploy: deploy:
needs: [lint, test, build] needs: [lint, test, build]
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
if: github.ref == 'refs/heads/main' #if: github.ref == 'refs/heads/main'
permissions: permissions:
contents: read contents: read
id-token: write id-token: write
@ -141,11 +142,11 @@ jobs:
- name: Set version number - name: Set version number
run: echo "VERSION_NUMBER=$(date +'%y%m%d.%H%M%S')" >> $GITHUB_ENV run: echo "VERSION_NUMBER=$(date +'%y%m%d.%H%M%S')" >> $GITHUB_ENV
- name: Building docker image - name: Building docker image
run: docker build -t git.targo.ca/targo/targo_frontend_staging:2.${{ env.VERSION_NUMBER }} . run: docker build -t git.targo.ca/targo/targo-frontend-staging:2.${{ env.VERSION_NUMBER }} .
- name: Add tag Latest - name: Add tag Latest
run: docker tag git.targo.ca/targo/targo_frontend_staging:2.${{ env.VERSION_NUMBER }} git.targo.ca/targo/targo_frontend_staging:latest run: docker tag git.targo.ca/targo/targo-frontend-staging:2.${{ env.VERSION_NUMBER }} git.targo.ca/targo/targo-frontend-staging:latest
- name: Push images to server - name: Push images to server
run: | run: |
docker login -u ${{ secrets.CI_USER }} -p ${{ secrets.CI_PASSWORD }} git.targo.ca docker login -u ${{ secrets.CI_USER }} -p ${{ secrets.CI_PASSWORD }} git.targo.ca
docker push git.targo.ca/targo/targo_frontend_staging:2.${{ env.VERSION_NUMBER }} docker push git.targo.ca/targo/targo-frontend-staging:2.${{ env.VERSION_NUMBER }}
docker push git.targo.ca/targo/targo_frontend_staging:latest docker push git.targo.ca/targo/targo-frontend-staging:latest

View File

@ -1,24 +1,15 @@
# Step 1 - Building the app
FROM node:22 AS build
WORKDIR /app
COPY package*.json ./
# Install dependencies
RUN npm install -g @quasar/cli
COPY . .
RUN npm ci
RUN npm run build
# Step 2 - Move Applicatin to Nginx
FROM nginx:alpine FROM nginx:alpine
COPY --from=build /app/dist/spa /usr/share/nginx/html
RUN mkdir /usr/share/nginx/html/src
COPY --from=build /app/src /usr/share/nginx/html/src
COPY env.sh /docker-entrypoint.d/env.sh #Copy files
RUN mkdir /usr/share/nginx/html/src
COPY dist/spa /usr/share/nginx/html
COPY source /usr/share/nginx/html/src
#Add script to replace VITE env vars
RUN curl -o /docker-entrypoint.d/env.sh -O https://raw.githubusercontent.com/Dutchskull/Vite-Dynamic-Environment-Variables/refs/heads/main/app/env.sh
RUN dos2unix /docker-entrypoint.d/env.sh RUN dos2unix /docker-entrypoint.d/env.sh
RUN chmod +x /docker-entrypoint.d/env.sh RUN chmod +x /docker-entrypoint.d/env.sh
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 80 EXPOSE 80
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]