From 896fe2f1b86fe1f9e97d0de8486f69fc07750b24 Mon Sep 17 00:00:00 2001 From: louis Date: Thu, 3 Oct 2024 13:16:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B3=20Add=20Docker=20Image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 10 +++++++++ .github/dependabot.yml | 5 +++++ .github/workflows/integration.yml | 3 +++ .gitignore | 1 + Dockerfile | 36 +++++++++++++++++++++++++++++++ docker-compose.yml | 13 +++++++++++ 6 files changed, 68 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..d70c67b --- /dev/null +++ b/.env.example @@ -0,0 +1,10 @@ +USERLI_TOKEN=insecure +USERLI_BASE_URL=http://localhost:8000 +ALIAS_LISTEN_ADDR=":10001" +DOMAIN_LISTEN_ADDR=":10002" +MAILBOX_LISTEN_ADDR=":10003" +SENDERS_LISTEN_ADDR=":10004" +METRICS_LISTEN_ADDR=":10005" + +LOG_LEVEL=debug +LOG_FORMAT=text diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c9bdbc9..1f3739e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -14,3 +14,8 @@ updates: directory: "/" schedule: interval: "monthly" + + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 158324c..04918b2 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -43,3 +43,6 @@ jobs: - name: Build run: go build + + - name: Docker Build + run: docker build . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1956178 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM golang:1.23-alpine3.19 AS build + +ENV USER=appuser +ENV UID=10001 + +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/nonexistent" \ + --shell "/sbin/nologin" \ + --no-create-home \ + --uid "${UID}" \ + "${USER}" + +WORKDIR /app + +COPY go.mod go.sum ./ + +RUN go mod download && go mod verify + +COPY . . + +RUN go build -ldflags="-s -w" -o ./userli-postfix-adapter + + +FROM scratch AS runtime + +COPY --from=build /app/userli-postfix-adapter /userli-postfix-adapter + +COPY --from=build /etc/passwd /etc/passwd +COPY --from=build /etc/group /etc/group +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt + +USER appuser:appuser + +ENTRYPOINT ["/userli-postfix-adapter"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4c4f319 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +--- +services: + adapter: + image: systemli/userli-postfix-adapter + build: . + ports: + - "10001:10001" + - "10002:10002" + - "10003:10003" + - "10004:10004" + - "10005:10005" + env_file: + - .env