From 7f0d99e1b52ee3414eaf61333780fb3ae0c1e7f5 Mon Sep 17 00:00:00 2001 From: ajutamang Date: Wed, 11 Sep 2024 12:56:22 +0545 Subject: [PATCH] feat: add dockerfile and actions to push image --- .github/workflows/image_build.yml | 26 ++++++++++++++++++++++++++ Dockerfile | 15 +++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .github/workflows/image_build.yml create mode 100644 Dockerfile diff --git a/.github/workflows/image_build.yml b/.github/workflows/image_build.yml new file mode 100644 index 0000000..746597d --- /dev/null +++ b/.github/workflows/image_build.yml @@ -0,0 +1,26 @@ +name: Build Docker Image +on: + push: + branches: + - main +jobs: + build: + name: push docker image to docker hub + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: login to docker hub + id: docker-hub + env: + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_PASSWORD}} + run: | + docker login -u $username -p $password + - name: build the docker image + id: build-docker-image + run: | + ls -la + docker build -t docker push ${{secrets.DOCKERHUB_USERNAME}}/s3khoj:latest + - name: push the docker image + id: push-docker-image + run: docker push ${{secrets.DOCKERHUB_USERNAME}}/s3khoj:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4a6231e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# Build +FROM golang:1.22-alpine AS build-env +RUN apk add build-base +WORKDIR /app +COPY . /app +RUN go mod tidy +RUN go build -o S3Khoj main.go + +# Release +FROM alpine:3.18.6 +RUN apk upgrade --no-cache \ + && apk add --no-cache bind-tools +COPY --from=build-env /app/S3Khoj /usr/local/bin/S3Khoj + +ENTRYPOINT [ "S3Khoj" ] \ No newline at end of file