Skip to content

Commit

Permalink
[build] add Docker release
Browse files Browse the repository at this point in the history
  • Loading branch information
capcom6 committed Oct 28, 2024
1 parent e16e855 commit 1e437d4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 18 deletions.
1 change: 1 addition & 0 deletions .dockerignore
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: stable
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
Expand Down
26 changes: 13 additions & 13 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ archives:
- goos: windows
format: zip

# dockers:
# - image_templates:
# - "capcom6/labeled-storage:{{ .Tag }}"
# - "capcom6/labeled-storage:v{{ .Major }}"
# - "capcom6/labeled-storage:v{{ .Major }}.{{ .Minor }}"
# - "capcom6/labeled-storage:latest"
# dockerfile: Dockerfile
# build_flag_templates:
# - "--label=org.opencontainers.image.created={{ .Date }}"
# - "--label=org.opencontainers.image.title={{ .ProjectName }}"
# - "--label=org.opencontainers.image.revision={{ .FullCommit }}"
# - "--label=org.opencontainers.image.version={{ .Version }}"
# skip_push: false
dockers:
- image_templates:
- "smsgate/cli:{{ .Tag }}"
- "smsgate/cli:v{{ .Major }}"
- "smsgate/cli:v{{ .Major }}.{{ .Minor }}"
- "smsgate/cli:latest"
dockerfile: Dockerfile
build_flag_templates:
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
skip_push: false

changelog:
sort: asc
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Start from the official Go image
FROM golang:1.23-alpine AS builder

# Set the working directory inside the container
WORKDIR /app

# Copy go mod and sum files
COPY go.mod go.sum ./

# Download all dependencies
RUN go mod download

# Copy the source code into the container
COPY . .

# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o smsgate ./cmd/smsgate

# Start a new stage from scratch
FROM alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /root/

# Copy the pre-built binary file from the previous stage
COPY --from=builder /app/smsgate .

# Command to run the executable
ENTRYPOINT ["./smsgate"]

0 comments on commit 1e437d4

Please sign in to comment.