Skip to content

Commit

Permalink
wip2 rtabby docker workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Clem-Fern committed Mar 10, 2024
1 parent b6b2cf3 commit 6cd87fe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/rtabby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ jobs:
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: ${{ github.event_name == 'release' }}
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
Expand All @@ -63,6 +67,7 @@ jobs:
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: ${{ github.event_name == 'release' }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
Expand Down Expand Up @@ -109,13 +114,15 @@ jobs:
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_COMMIT=${{ steps.prep.outputs.GIT_COMMIT }}
FEATURE_FLAGS=-F|${{ matrix.db }}-bundle${{ matrix.minimal && '' || '|-F|all-login' }}
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
default = ["mysql", "all-login"]
dotenv = ["dep:dotenvy"]
mysql = ["diesel/mysql"]
mysqlclient-static = ["mysql"]
mysqlclient-bundle = ["mysql"]
sqlite = ["diesel/sqlite"]
sqlite-bundle = ["sqlite", "libsqlite3-sys/bundled"]
third-party-login = ["dep:actix-session", "dep:tera", "dep:reqwest", "dep:actix-files"]
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# syntax=docker/dockerfile:1
FROM rust:1.76-alpine AS builder
ARG FEATURE_FLAGS="-F|mysqlclient-static|-F|github-login"
ARG FEATURE_FLAGS="-F|mysqlclient-bundle|-F|all-login"
WORKDIR /build
COPY . .

RUN apk add --no-cache build-base

RUN if [[ "$FEATURE_FLAGS" == *"mysqlclient-static"* ]]; then \
RUN if [[ "$FEATURE_FLAGS" == *"mysqlclient-bundle"* ]]; then \
apk add --no-cache binutils mariadb-dev musl-dev bash cmake curl && \
bash scripts/mariadb-static-build.sh && \
bash scripts/zlib-static-build.sh && \
Expand All @@ -24,14 +24,14 @@ RUN if [[ "$FEATURE_FLAGS" == *"login"* ]]; then \
fi


RUN cargo build --target=x86_64-unknown-linux-musl --release $(echo "$FEATURE_FLAGS" | sed 's/|/ /g')
RUN cargo build --release --no-default-features --target-dir /build/target/docker $(echo "$FEATURE_FLAGS" | sed 's/|/ /g')

FROM scratch
ARG GIT_COMMIT

WORKDIR /config

COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/rtabby-web-api /
COPY --from=builder /build/target/docker/release/rtabby-web-api /
COPY --from=builder /build/users.exemple.yml .
COPY --from=builder /build/web/ /www/web/
ENV STATIC_FILES_BASE_DIR=/www/web/
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
fn main() {
#[cfg(feature = "mysqlclient-static")]
#[cfg(feature = "mysqlclient-bundle")]
mysqlclient_static();
}

#[cfg(feature = "mysqlclient-static")]
#[cfg(feature = "mysqlclient-bundle")]
fn mysqlclient_static() {
println!("cargo:rustc-link-search=native=lib");
println!("cargo:rustc-link-lib=static=mysqlclient");
Expand Down

0 comments on commit 6cd87fe

Please sign in to comment.