-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
f55a5eb
commit 08871e1
Showing
3 changed files
with
84 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: | ||
- "master" | ||
|
||
jobs: | ||
docker_image: | ||
name: Build & push docker image to DockerHub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ secrets.DOCKERHUB_REPO }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build & push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
platforms: linux/amd64, linux/arm64 | ||
push: ${{ github.ref_type == 'tag' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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
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,23 +1,27 @@ | ||
# latest rust will be used to build the binary | ||
FROM rust:latest as builder | ||
FROM rust:latest as build | ||
|
||
# the temporary directory where we build | ||
WORKDIR /usr/src/microbin | ||
WORKDIR /app | ||
|
||
# copy sources to /usr/src/microbin on the temporary container | ||
COPY . . | ||
|
||
# run release build | ||
RUN cargo build --release | ||
RUN \ | ||
DEBIAN_FRONTEND=noninteractive \ | ||
apt-get update &&\ | ||
apt-get -y install ca-certificates tzdata &&\ | ||
cargo build --release | ||
|
||
# create final container using slim version of debian | ||
FROM debian:buster-slim | ||
FROM debian:bullseye-slim | ||
|
||
# microbin will be in /usr/local/bin/microbin/ | ||
WORKDIR /usr/local/bin | ||
WORKDIR /app | ||
|
||
# copy built exacutable | ||
COPY --from=builder /usr/src/microbin/target/release/microbin /usr/local/bin/microbin | ||
COPY --from=build \ | ||
/usr/share/zoneinfo \ | ||
/usr/share/zoneinfo | ||
COPY --from=build \ | ||
/etc/ssl/certs/ca-certificates.crt \ | ||
/etc/ssl/certs/ca-certificates.crt | ||
COPY --from=build \ | ||
/app/target/release/microbin \ | ||
/usr/bin/microbin | ||
|
||
# run the binary | ||
CMD ["microbin"] | ||
ENTRYPOINT ["microbin"] |