File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Docker Image
2+
3+ on :
4+ push :
5+ tags : [ 'v*.*.*' ]
6+
7+ jobs :
8+ docker :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - uses : actions/checkout@v4
12+ - name : Set up Docker Buildx
13+ uses : docker/setup-buildx-action@v3
14+ - name : Login to GitHub Container Registry
15+ uses : docker/login-action@v3
16+ with :
17+ registry : ghcr.io
18+ username : ${{ github.actor }}
19+ password : ${{ secrets.GITHUB_TOKEN }}
20+ - name : Build and push Docker image
21+ uses : docker/build-push-action@v5
22+ with :
23+ context : .
24+ push : true
25+ tags : |
26+ ghcr.io/${{ github.repository }}:${{ github.ref_name }}
27+ ghcr.io/${{ github.repository }}:latest
28+ build-args : |
29+ VERSION=${{ github.ref_name }}
Original file line number Diff line number Diff line change 1+ name : Lint
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ lint :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+ - name : Set up Go
15+ uses : actions/setup-go@v5
16+ with :
17+ go-version : ' 1.22'
18+ - name : Run go fmt
19+ run : go fmt ./...
20+ - name : Run go vet
21+ run : go vet ./...
Original file line number Diff line number Diff line change 1+ name : Release
2+
3+ on :
4+ push :
5+ tags : [ 'v*.*.*' ]
6+
7+ jobs :
8+ release :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - uses : actions/checkout@v4
12+ - name : Set up Go
13+ uses : actions/setup-go@v5
14+ with :
15+ go-version : ' 1.22'
16+ - name : Build
17+ run : go build -ldflags "-X main.version=${GITHUB_REF_NAME}" -v ./...
18+ - name : Create GitHub Release
19+ uses : softprops/action-gh-release@v2
20+ with :
21+ files : |
22+ ./web_proxy_cache
Original file line number Diff line number Diff line change 1+ # Build stage
2+ FROM golang:1.22-alpine AS builder
3+ WORKDIR /app
4+ COPY go.mod go.sum ./
5+ RUN go mod download
6+ COPY . .
7+ ARG VERSION=dev
8+ RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.version=${VERSION}" -o web_proxy_cache .
9+
10+ # Final image
11+ FROM alpine:3.19
12+ WORKDIR /app
13+ COPY --from=builder /app/web_proxy_cache .
14+ EXPOSE 8080
15+ ENTRYPOINT ["./web_proxy_cache" ]
You can’t perform that action at this time.
0 commit comments