Skip to content

Commit 5ca8f5a

Browse files
Add github action
1 parent 45a31d2 commit 5ca8f5a

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ rj-docker-build ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v3
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+
- name: Build and push
26+
uses: docker/build-push-action@v5
27+
with:
28+
context: .
29+
push: true
30+
tags: audius/api:latest
31+
cache-from: type=registry,ref=audius/api:buildcache
32+
cache-to: type=registry,ref=audius/api:buildcache,mode=max

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM golang:1.22-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
COPY go.mod go.sum ./
6+
7+
RUN go mod download
8+
9+
COPY . .
10+
11+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bridge-amd64 main.go
12+
13+
FROM alpine:latest
14+
15+
WORKDIR /app
16+
17+
COPY --from=builder /app/bridge-amd64 /bin/bridge
18+
19+
EXPOSE 1323
20+
21+
CMD ["bridge"]

0 commit comments

Comments
 (0)