Skip to content

Commit

Permalink
ci: add publish pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioromagnollo committed Oct 11, 2023
1 parent 6f1f681 commit f7c69ad
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and Publish Docker Image

on:
push:
branches:
- master

env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

jobs:
build:
name: Build and Publish
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build the Docker image
run: |
docker build -t mauricioromagnollo/kafka-rest:latest .
- name: Login to Docker Hub
run: |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
- name: Publish Docker Image to Docker Hub
if: success()
run: |
docker push mauricioromagnollo/kafka-rest
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.20.6 as builder
WORKDIR /app
COPY . .
RUN GOOS=linux go build -ldflags="-w -s" -o bin/api cmd/api/main.go

FROM scratch
COPY --from=builder /app/bin/api .
EXPOSE 8080
CMD [ "./api" ]

0 comments on commit f7c69ad

Please sign in to comment.