-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build post-service Docker img in CI (#136)
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 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,2 @@ | ||
target | ||
service/api/bin |
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,33 @@ | ||
name: Docker Build and Push | ||
|
||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./service/Dockerfile | ||
push: true | ||
tags: spacemeshos/post-service:latest, spacemeshos/post-service:${{ GITHUB.SHA }}, spacemeshos/post-service:${{ github.ref_name }} | ||
|
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,28 @@ | ||
FROM rust:1 AS chef | ||
|
||
RUN cargo install cargo-chef | ||
RUN apt-get update && apt-get install -y\ | ||
llvm-dev \ | ||
libclang-dev \ | ||
clang \ | ||
cmake \ | ||
protobuf-compiler \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /service | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef AS builder | ||
COPY --from=planner /service/recipe.json recipe.json | ||
RUN cargo chef cook --release -p service --recipe-path recipe.json | ||
|
||
COPY . . | ||
RUN cargo build --release -p service --bin service | ||
|
||
FROM debian:bookworm-slim AS runtime | ||
WORKDIR /service | ||
COPY --from=builder /service/target/release/service /usr/local/bin | ||
ENTRYPOINT ["/usr/local/bin/service"] |