-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7abf792
commit 0f10496
Showing
2 changed files
with
89 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,91 @@ | ||
name: Build | ||
run-name: 'Build ${{ github.ref_name }} by ${{ github.actor }}' | ||
name: Create and push a Docker image | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
VERSION: $GITHUB_SHA | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- rust_arch: aarch64-unknown-linux-gnu | ||
docker_arch: arm64 | ||
- rust_arch: x86_64-unknown-linux-gnu | ||
docker_arch: amd64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo build --release | ||
- uses: tweedegolf/create-tag-action@main | ||
- uses: tweedegolf/build-container-image@main | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Rust toolchain | ||
uses: dtolnay/rust-toolchain@7164405e8653277d57afd42ba081b5aa02a70396 | ||
with: | ||
toolchain: stable | ||
|
||
- name: Install cross | ||
uses: taiki-e/install-action@f8a64c940979268d3ab5ac99c178e718ed90977d # v2.32.14 | ||
with: | ||
tool: cross | ||
|
||
- name: Build | ||
run: | | ||
cross build --release --target ${{ matrix.rust_arch }} | ||
mv target/${{ matrix.rust_arch }}/release/tgcheck tgcheck.${{ matrix.docker_arch }} | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 | ||
with: | ||
name: tgcheck-${{ matrix.rust_arch }} | ||
path: tgcheck.${{ matrix.docker_arch }} | ||
if-no-files-found: error | ||
|
||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create version tag | ||
id: version | ||
run: echo "tag=$(git show -s --format="%ct-%h" $GITHUB_SHA)" >> $GITHUB_OUTPUT | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 | ||
with: | ||
pattern: "tgcheck-*" | ||
merge-multiple: true | ||
|
||
- name: Log in to the container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: Dockerfile | ||
pull: true | ||
push: true | ||
tags: ghcr.io/${{ github.repository}}:latest | ||
platforms: linux/amd64,linux/arm64 | ||
context: . | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
build-args: VERSION=${{ steps.version.outputs.tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
FROM ghcr.io/tweedegolf/debian:bookworm | ||
|
||
ARG TARGETARCH | ||
|
||
RUN useradd -c "Application" -m -U app | ||
ENV ROOT_SWITCH_USER=app | ||
ENV VERSION=$VERSION | ||
ENV TZ=Europe/Amsterdam | ||
WORKDIR /app | ||
USER app | ||
COPY ./target/release/tgcheck /usr/bin/tgcheck | ||
ENTRYPOINT [ "docker-entrypoint", "/usr/bin/tgcheck" ] | ||
|
||
# copy executable | ||
COPY tgcheck.$TARGETARCH /usr/local/bin/tgcheck | ||
RUN chmod 0755 /usr/local/bin/tgcheck | ||
|
||
# run tgcheck | ||
CMD ["/usr/local/bin/tgcheck"] |