From 287fd46db034419efd43ffbe2fb913ef2a351e3a Mon Sep 17 00:00:00 2001 From: Rui Lopes Date: Wed, 1 May 2024 19:10:51 +0100 Subject: [PATCH] init --- .github/workflows/build.yml | 30 ++++++ .gitignore | 1 + .vscode/settings.json | 8 ++ Dockerfile | 43 ++++++++ README.md | 9 ++ build.sh | 8 ++ go.mod | 35 +++++++ go.sum | 78 +++++++++++++++ main.go | 189 ++++++++++++++++++++++++++++++++++++ release.sh | 24 +++++ 10 files changed, 425 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 build.sh create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100755 release.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9321467 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +name: build +on: + - push +jobs: + build: + name: Build + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Build + run: ./build.sh + release: + if: startsWith(github.ref, 'refs/tags/v') + name: Release + needs: build + runs-on: ubuntu-22.04 + permissions: + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Release + run: ./release.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c052c68 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +aws-docdb-example diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..35f2286 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "cSpell.words": [ + "bson", + "DOCDB", + "terramate", + "Upsert" + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..12eeedf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +# syntax=docker.io/docker/dockerfile:1.7 +FROM golang:1.22-bookworm as builder +WORKDIR /app +COPY go.* ./ +RUN go mod download +COPY *.go . +ARG APP_VERSION='0.0.0-dev' +ARG APP_REVISION='0000000000000000000000000000000000000000' +RUN CGO_ENABLED=0 go build -ldflags="-s -X main.version=${APP_VERSION} -X main.revision=${APP_REVISION}" + +# NB we use the bookworm-slim (instead of scratch) image so we can enter the container to execute bash etc. +FROM debian:bookworm-slim +RUN <