Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build post-service Docker img in CI #136

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
service/api/bin
33 changes: 33 additions & 0 deletions .github/workflows/docker.yml
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 }}

28 changes: 28 additions & 0 deletions service/Dockerfile
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"]
Loading