fix: docker build
This commit is contained in:
parent
1a01baffb3
commit
25aa5fd880
1 changed files with 70 additions and 69 deletions
|
|
@ -1,69 +1,70 @@
|
||||||
name: Build and Deploy Go App
|
name: Build and Deploy Go App
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- cicd
|
- cicd
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/setup-go@v6
|
||||||
uses: actions/checkout@v4
|
with:
|
||||||
|
go-version: '^1.25'
|
||||||
- uses: actions/setup-go@v6
|
|
||||||
with:
|
- name: Set up Docker Buildx
|
||||||
go-version: '^1.25'
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Checkout code
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Build application
|
# Build application
|
||||||
- name: Build Go app
|
- name: Build Go app
|
||||||
run: |
|
run: |
|
||||||
cd modules/server
|
cd modules/server
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build -o nyanimedb .
|
go build -o nyanimedb .
|
||||||
|
|
||||||
- name: Upload built application to artifactory
|
- name: Upload built application to artifactory
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: nyanimedb
|
name: nyanimedb
|
||||||
path: modules/server/nyanimedb
|
path: modules/server/nyanimedb
|
||||||
|
|
||||||
# Build Docker image
|
# Build Docker image
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ vars.REGISTRY }}
|
registry: ${{ vars.REGISTRY }}
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
push: true
|
file: Dockerfiles/Dockerfile-server
|
||||||
tags: meowgit.nekoea.red/nihonium/nyanimedb:latest
|
push: true
|
||||||
|
tags: meowgit.nekoea.red/nihonium/nyanimedb:latest
|
||||||
deploy:
|
|
||||||
runs-on: self-hosted
|
deploy:
|
||||||
needs: build
|
runs-on: self-hosted
|
||||||
env:
|
needs: build
|
||||||
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
|
env:
|
||||||
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
|
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
|
||||||
POSTGRES_DB: nyanimedb
|
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
|
||||||
POSTGRES_PORT: 5432
|
POSTGRES_DB: nyanimedb
|
||||||
POSTGRES_VERSION: 18
|
POSTGRES_PORT: 5432
|
||||||
LOG_LEVEL: ${{ vars.LOG_LEVEL }}
|
POSTGRES_VERSION: 18
|
||||||
|
LOG_LEVEL: ${{ vars.LOG_LEVEL }}
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
steps:
|
||||||
uses: actions/checkout@v4
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
- name: Deploy containers locally
|
|
||||||
run: |
|
- name: Deploy containers locally
|
||||||
cd deploy
|
run: |
|
||||||
docker compose down || true
|
cd deploy
|
||||||
docker compose up -d
|
docker compose down || true
|
||||||
|
docker compose up -d
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue