Skip to content

Commit

Permalink
ci: build docker image and publish to docker hub
Browse files Browse the repository at this point in the history
  • Loading branch information
Shin-Thant committed Mar 7, 2024
1 parent aa754d8 commit d281d17
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Docker Image
on:
push:
branches:
- main
jobs:
push_to_registery:
name: Push Docker Image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Login in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags and labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: shinthant101/gograte

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:bullseye

WORKDIR /app

RUN go install github.com/Shin-Thant/gograte/cmd/gograte@latest

# 1. /bin/bash - start the interactive shell
# 2. -c - pass the following command to the shell
# 3. cd /app - change the working directory to /app
# 4. /bin/bash - start the interactive shell in the new working directory
CMD ["/bin/bash", "-c", "cd /app && /bin/bash"]

# docker run --name gograte_db -e POSTGRES_PASSWORD=pwd -e POSTGRES_USER=postgres -p 5000:5432 postgres:bullseye

0 comments on commit d281d17

Please sign in to comment.