-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from Concordium/lma/rust/release_flow
Rust release flow
- Loading branch information
Showing
4 changed files
with
99 additions
and
1 deletion.
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
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,71 @@ | ||
name: Release CCDScan Backend | ||
|
||
on: | ||
push: | ||
tags: | ||
- ccdscan-backend/* | ||
|
||
jobs: | ||
release-docker: | ||
runs-on: ubuntu-latest | ||
environment: release | ||
steps: | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: 'concordium' | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Clone repo | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set image tag if correctly formatted | ||
env: | ||
TAG: ${{ github.ref_name }} | ||
run: | | ||
TAG_VERSION=${TAG##ccdscan-backend/} | ||
EXPECTED=$(yq .package.version Cargo.toml) | ||
EXTRACTED="$TAG_VERSION" | ||
if [ ! "$EXPECTED" = "$EXTRACTED" ] ; then | ||
echo "::error::$EXPECTED does not match $EXTRACTED." | ||
exit 1 | ||
fi | ||
echo "TAG_VERSION=${TAG_VERSION}" >> $GITHUB_ENV | ||
- name: Check if images exists | ||
run: | | ||
set +e | ||
docker manifest inspect concordium/ccdscan-indexer:$TAG_VERSION | ||
EXITCODE=$? | ||
if [ $EXITCODE -eq "0" ]; then | ||
echo "::error::concordium/ccdscan-indexer:$TAG_VERSION already exists." | ||
exit 1 | ||
fi | ||
docker manifest inspect concordium/ccdscan-api:$TAG_VERSION | ||
EXITCODE=$? | ||
if [ $EXITCODE -eq "0" ]; then | ||
echo "::error::concordium/ccdscan-api:$TAG_VERSION already exists." | ||
exit 1 | ||
fi | ||
- name: Build indexer docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: backend-rust | ||
file: backend-rust/Dockerfile | ||
tags: concordium/ccdscan-indexer:${{ env.TAG_VERSION }} | ||
push: true | ||
build-args: | | ||
target_binary=ccdscan-indexer | ||
- name: Build api docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: backend-rust | ||
file: backend-rust/Dockerfile | ||
tags: concordium/ccdscan-api:${{ env.TAG_VERSION }} | ||
push: true | ||
build-args: | | ||
target_binary=ccdscan-api |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ARG build_image=rust:1.82-bookworm | ||
ARG base_image=debian:bookworm-slim | ||
ARG target_binary | ||
FROM ${build_image} AS build | ||
|
||
WORKDIR /usr/app | ||
|
||
COPY Cargo.toml Cargo.lock ./ | ||
COPY src ./src | ||
COPY concordium-rust-sdk /usr/app/concordium-rust-sdk | ||
COPY .sqlx .sqlx | ||
RUN cargo install sqlx-cli --no-default-features --features "postgres" | ||
RUN cargo build --release --locked | ||
|
||
|
||
FROM ${base_image} | ||
|
||
WORKDIR /usr/app | ||
|
||
COPY migrations /usr/app/migrations | ||
COPY --from=build /usr/app/target/release/${target_binary} /usr/bin/ | ||
COPY --from=build /usr/local/cargo/bin/sqlx /usr/local/bin/sqlx | ||
|
||
RUN chmod +x /usr/bin/${target_binary} | ||
CMD ["/usr/bin/${target_binary}"] |