diff --git a/.github/workflows/publish-package-ghcr.yaml b/.github/workflows/publish-package-ghcr.yaml new file mode 100644 index 0000000..29a0a8d --- /dev/null +++ b/.github/workflows/publish-package-ghcr.yaml @@ -0,0 +1,21 @@ +name: Docker Image CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build the Docker image + run: | + docker login --username gkeesh7 --password ${{ secrets.GH_PAT }} ghcr.io + docker build . --file Dockerfile --tag ghcr.io/gkeesh7/url-shortner:latest + docker push ghcr.io/gkeesh7/url-shortner:latest diff --git a/Dockerfile b/Dockerfile index 0048951..a5ff117 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM golang:1.16-alpine +FROM golang:1.17-alpine RUN apk update RUN apk add git @@ -10,7 +10,7 @@ ENV PKG_PATH=$GOPATH/src/$PKG_NAME WORKDIR $PKG_PATH COPY . $PKG_PATH -RUN go env -w GO111MODULE=off +RUN go mod download RUN go build main.go WORKDIR $PKG_PATH diff --git a/README.md b/README.md index 78bd121..3b6a997 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,11 @@ kubectl port-forward deployment/url-shortner-deployment 8080:8080 ``` The guide to make sure that the docker image gets built and pulled locally is [here](https://stackoverflow.com/questions/42564058/how-to-use-local-docker-images-with-minikube) +For windows machines incase ```eval $(minikube docker-env)``` might not work so save the image to a tar file and put into minikube +``` +docker image save -o image.tar my_image:tag +minikube image load image.tar +``` #### Unit Testing and Perf Testing For unit testing you can run the go test command and get the test coverage for the project