From 37b00d43ba1a61c5c95394f00fdd4e358518f750 Mon Sep 17 00:00:00 2001 From: charlocharlie Date: Sat, 10 Feb 2024 19:52:31 -0600 Subject: [PATCH 1/4] Improve Dockerfile and add build CI action --- .github/workflows/build-and-push-image.yml | 48 ++++++++++++++++++++++ Dockerfile | 15 ++++++- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-and-push-image.yml diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml new file mode 100644 index 0000000..ea97fea --- /dev/null +++ b/.github/workflows/build-and-push-image.yml @@ -0,0 +1,48 @@ +name: Docker Build + +on: + push: + branches: + - main + +jobs: + docker-build: + name: Build and push Docker image + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + target: deploy + push: true + tags: ${{ steps.meta.outputs.tags }} + platforms: linux/amd64 + cache-from: type=gha,scope=${{ github.workflow }} + cache-to: type=gha,mode=max,scope=${{ github.workflow }} diff --git a/Dockerfile b/Dockerfile index 94d6398..fc5bed1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,22 @@ -FROM denoland/deno:latest +FROM denoland/deno:alpine # The port that your application listens to. EXPOSE 43385 +VOLUME [ "/logs" ] + WORKDIR /app +# Symlink stats.json into a volume, as it's hard to mount from the workdir +RUN mkdir /logs && ln -s /logs/stats.json ./stats.json && chown -R deno:deno /logs + # Prefer not to run as root. USER deno -CMD ["run", "--allow-all", "https://raw.githubusercontent.com/garrettjoecox/anchor/main/mod.ts"] +# Copy in source code +COPY *.ts . + +# Compile the main app so that it doesn't need to be compiled each startup/entry. +RUN deno cache mod.ts + +CMD ["run", "--allow-net", "--allow-env", "--allow-write", "mod.ts"] From b0a637de19e275be539f5e55fe28caad58071ce6 Mon Sep 17 00:00:00 2001 From: charlocharlie Date: Sat, 10 Feb 2024 20:17:25 -0600 Subject: [PATCH 2/4] Fix docker target --- .github/workflows/build-and-push-image.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index ea97fea..04d78cb 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -40,7 +40,6 @@ jobs: - name: Build and push uses: docker/build-push-action@v5 with: - target: deploy push: true tags: ${{ steps.meta.outputs.tags }} platforms: linux/amd64 From d83a64160a05cafd3b93bde19c9af33370a59a99 Mon Sep 17 00:00:00 2001 From: charlocharlie Date: Sat, 10 Feb 2024 20:29:49 -0600 Subject: [PATCH 3/4] Add Docker instructions to readme --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 75af0f9..6dc95ef 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,17 @@ deno run --allow-net --allow-read mod.ts +"gRemoteGIIP": "127.0.0.1", ``` +### Docker + +```sh +docker run -p 43385:43385 -v /my/mnt/logs:/logs ghcr.io/garrettjoecox/anchor:latest +``` + +Optional environment variables can be set: + +- `PORT`: configures the server port inside the container; defaults to `43385` +- `QUIET`: when set, fewer log messages are output; defaults to unset + ## Packet protocol > This is for anyone wanting to extend the client side of anchor while still From 7e8903c8003c2250a451dea28c4565ed92f0f7b1 Mon Sep 17 00:00:00 2001 From: charlocharlie Date: Mon, 4 Mar 2024 11:55:03 -0600 Subject: [PATCH 4/4] Add arm64 build, deno supports it now --- .github/workflows/build-and-push-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index 04d78cb..8112f3b 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -42,6 +42,6 @@ jobs: with: push: true tags: ${{ steps.meta.outputs.tags }} - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 cache-from: type=gha,scope=${{ github.workflow }} cache-to: type=gha,mode=max,scope=${{ github.workflow }}