From 85eff4fd460b2dc9391ccbde0db17cc3b0a4b54a Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sat, 17 Jun 2023 00:29:49 +0200 Subject: [PATCH] Set-up Docker and GitHub Actions --- .github/FUNDING.yml | 3 ++ .../docker-publish-anisette-v3-server.yml | 27 +++++++++++++++ Dockerfile | 34 +++++++++++++++++++ dub.json | 22 +++++++++++- dub.selections.json | 12 ++----- 5 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/docker-publish-anisette-v3-server.yml create mode 100644 Dockerfile diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..49ef756 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: ["Dadoum"] diff --git a/.github/workflows/docker-publish-anisette-v3-server.yml b/.github/workflows/docker-publish-anisette-v3-server.yml new file mode 100644 index 0000000..61712db --- /dev/null +++ b/.github/workflows/docker-publish-anisette-v3-server.yml @@ -0,0 +1,27 @@ +name: Publish docker image anisette-v3-server + +on: + push: + branches: + - 'main' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + push: true + tags: | + dadoum/anisette-v3-server:latest + platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..305f8c8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# Base for builder +FROM debian:unstable-slim AS builder +# Deps for builder +RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates ldc git clang dub libz-dev libssl-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Build for builder +WORKDIR /opt/ +COPY . . +RUN DC=ldc2 dub build -c "static" --build-mode allAtOnce -b release --compiler=ldc2 + +# Base for run +FROM debian:unstable-slim +RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates curl \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Copy build artefacts to run +WORKDIR /opt/ +COPY --from=builder /opt/anisette-v3-server /opt/anisette-v3-server + +# Setup rootless user which works with the volume mount +RUN useradd -ms /bin/bash Alcoholic \ + && mkdir /home/Alcoholic/.config/anisette-v3/lib/ -p \ + && chown -R Alcoholic /home/Alcoholic/ \ + && chmod -R +wx /home/Alcoholic/ \ + && chown -R Alcoholic /opt/ \ + && chmod -R +wx /opt/ + +# Run the artefact +USER Alcoholic +EXPOSE 6969 +ENTRYPOINT [ "/opt/anisette-v3-server" ] diff --git a/dub.json b/dub.json index ef58fbb..dad43ca 100644 --- a/dub.json +++ b/dub.json @@ -12,5 +12,25 @@ }, "slf4d": "~>2.1.1", "vibe-d": "~>0.9.7-alpha.2" - } + }, + + "configurations": [ + { + "name": "default", + "targetType": "executable" + }, + { + "name": "static", + "targetType": "executable", + "lflags-linux-ldc": [ + "-lz" + ], + "dflags-ldc": [ + "--link-defaultlib-shared=false" + ], + "dflags-gdc": [ + "-defaultlib=:libgphobos.a" + ] + } + ] } \ No newline at end of file diff --git a/dub.selections.json b/dub.selections.json index 029ab1b..b1bffb8 100644 --- a/dub.selections.json +++ b/dub.selections.json @@ -4,13 +4,7 @@ "diet-ng": "1.8.1", "dxml": "0.4.3", "eventcore": "0.9.25", - "hunt": "1.7.17", - "hunt-extra": "1.2.3", - "hunt-http": "0.8.2", - "hunt-net": "0.7.1", - "hunt-openssl": "1.0.5", - "libasync": "0.9.2", - "lighttp": "0.5.4", + "libasync": "0.8.6", "memutils": "1.0.9", "mir-linux-kernel": "1.0.1", "openssl": "3.3.0", @@ -21,9 +15,7 @@ "slf4d": "2.1.1", "stdx-allocator": "2.77.5", "taggedalgebraic": "0.11.22", - "urld": "2.1.1", "vibe-core": "2.2.0", - "vibe-d": "0.9.7-alpha.2", - "xbuffer": "1.0.0" + "vibe-d": "0.9.7-alpha.2" } }