From 300bc6823489449ed2fa42295be1016b2f4beec7 Mon Sep 17 00:00:00 2001 From: bay <{ID}+{username}@users.noreply.github.com> Date: Mon, 10 Jul 2023 16:30:59 +0200 Subject: [PATCH 1/2] added basic docker image --- .github/workflows/docker.yml | 42 ++++++++++++++++++++++++++++++++++++ Dockerfile | 18 ++++++++++++++++ docker-compose.example.yml | 34 +++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile create mode 100644 docker-compose.example.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..bca77a7 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,42 @@ +name: Create and publish a Docker image + +on: + push: + tags: + - v* + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.CR_PAT }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a3a4bfb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM golang as build-env + +WORKDIR /go/src/app +COPY . /go/src/app + +RUN go get -d -v ./... + +RUN go install github.com/golang/mock/mockgen@v1.6.0 + +RUN ./update_mocks.sh + +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /go/bin/app /go/src/app/ + +FROM gcr.io/distroless/base + +COPY --from=build-env /go/bin/app /app + +CMD ["/app"] \ No newline at end of file diff --git a/docker-compose.example.yml b/docker-compose.example.yml new file mode 100644 index 0000000..d092e55 --- /dev/null +++ b/docker-compose.example.yml @@ -0,0 +1,34 @@ +version: '3' + +services: + app: + build: . + container_name: app + restart: unless-stopped + ports: + - 3000:3000 + volumes: + - ./config.example.yaml:/config.yaml + + + nginx: + image: nginx + container_name: nginx + restart: unless-stopped + ports: + - 80:80 + - 443:443 + volumes: + - ./certs:/etc/letsencrypt + - ./nginx.conf:/etc/nginx/nginx.conf + depends_on: + - app + + certbot: + image: certbot/certbot + container_name: certbot + restart: unless-stopped + volumes: + - ./certs:/etc/letsencrypt + - ./certbot/conf:/etc/letsencrypt + command: certonly --webroot --webroot-path=/var/www/certbot --email= --agree-tos --no-eff-email --staging -d \ No newline at end of file From 817bf7686abb4f5334d29f7a08789faa8c83293a Mon Sep 17 00:00:00 2001 From: bay <{ID}+{username}@users.noreply.github.com> Date: Thu, 27 Jul 2023 21:23:13 +0200 Subject: [PATCH 2/2] removed mocks --- Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a3a4bfb..2b3ac0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,6 @@ COPY . /go/src/app RUN go get -d -v ./... -RUN go install github.com/golang/mock/mockgen@v1.6.0 - -RUN ./update_mocks.sh - RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /go/bin/app /go/src/app/ FROM gcr.io/distroless/base