From b601ab5eac6f5a26ed0c11e4bb6af0f265c5e121 Mon Sep 17 00:00:00 2001 From: Frank Yang Date: Thu, 10 Nov 2022 22:53:51 +0800 Subject: [PATCH] ci: bump version and push docker image Signed-off-by: Frank Yang --- .github/workflows/release.yaml | 41 ++++++++++++++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- Dockerfile | 24 ++++++++++++++++++++ Makefile | 4 ++++ 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b955b770..b00f1868 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -153,3 +153,44 @@ jobs: - name: Cargo publish run: cargo publish shell: bash + docker-image: + name: Build and push docker images + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: lowercase repository owner + run: | + echo "OWNER=${GITHUB_REPOSITORY_OWNER,,}" >>$GITHUB_ENV + - name: set the release version (tag) + if: startsWith(github.ref, 'refs/tags/v') + shell: bash + run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Build and push (tag) + uses: docker/build-push-action@v3 + if: startsWith(github.ref, 'refs/tags/v') + with: + push: true + tags: ghcr.io/${{ env.OWNER }}/bindle:latest,ghcr.io/${{ env.OWNER }}/bindle:${{ env.RELEASE_VERSION }} + + - name: Build and push (main) + uses: docker/build-push-action@v3 + if: github.ref == 'refs/heads/main' + with: + push: true + tags: ghcr.io/${{ env.OWNER }}/bindle:canary diff --git a/Cargo.lock b/Cargo.lock index 48856beb..59734145 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,7 +103,7 @@ dependencies = [ [[package]] name = "bindle" -version = "0.8.0" +version = "0.8.3" dependencies = [ "anyhow", "async-compression", diff --git a/Cargo.toml b/Cargo.toml index 60ef2bc1..5ba7b46c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bindle" -version = "0.8.0" +version = "0.8.3" authors = [ "Matt Butcher ", "Taylor Thomas " diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..85d44369 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM rust:1.64 as builder + +WORKDIR /app +COPY . /app +RUN cargo build --release --all-features --bin bindle-server + +FROM debian:bullseye-slim + +ARG USERNAME=bindle +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +VOLUME [ "/bindle-data" ] + +ENV BINDLE_IP_ADDRESS_PORT="0.0.0.0:8080" +ENV BINDLE_DIRECTORY="/bindle-data/bindles" + +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME + +COPY --from=builder --chown=$USERNAME /app/target/release/bindle-server /usr/local/bin/bindle-server + +USER $USERNAME +CMD ["/usr/local/bin/bindle-server", "--unauthenticated"] diff --git a/Makefile b/Makefile index fbd4fc72..1d4b9a2a 100644 --- a/Makefile +++ b/Makefile @@ -80,3 +80,7 @@ build-client: $(CERT_NAME).crt.pem: openssl req -newkey rsa:2048 -nodes -keyout $(CERT_NAME).key.pem -x509 -days 365 -out $(CERT_NAME).crt.pem + +.PHONY: build-docker-image +build-docker-image: + docker build -t fermyon/bindle:dev .