Skip to content

Commit

Permalink
ci: 构建backend镜像
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Apr 11, 2024
1 parent 08f1d72 commit 575f86f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/build-latest-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build Backend Latest Image

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go 1.22.1
uses: actions/setup-go@v2
with:
go-version: 1.22.1

- name: Build the backend
run: |
go build -o bin/campux main.go
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/campux-backend:latest

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ campux.yaml

# container files
docker/mongodb/mongodata
docker/minio/data
docker/minio/data

/bin
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.22.1

WORKDIR /app

COPY bin/campux /app/campux

EXPOSE 8080

ENV GIN_MODE=release

CMD ["./campux"]

0 comments on commit 575f86f

Please sign in to comment.