diff --git a/.dockerignore b/.dockerignore index af4888c78..ab1a59b1c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,5 @@ target -Dockerfile +dockerfile .dockerignore .env .git diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6dfa7f0a6..e2eea0beb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -41,6 +41,8 @@ jobs: images: joepmeneer/atomic-server github-token: ${{ secrets.GITHUB_TOKEN }} tags: | + # set latest tag for master branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} type=schedule type=ref,event=branch type=ref,event=pr @@ -58,3 +60,13 @@ jobs: platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + - name: Run docker image + run: nohup docker run -p 80:80 joepmeneer/atomic-server:develop --initialize & + + - name: Setup and run end-to-end tests + working-directory: ./server/e2e_tests/ + run: | + pnpm install + pnpm run install-playwright + pnpm run test diff --git a/dockerfile b/dockerfile index 04b09db1b..a75985c14 100644 --- a/dockerfile +++ b/dockerfile @@ -1,11 +1,23 @@ -FROM rust:1.67 as builder +FROM clux/muslrust:stable AS builder +# Install musl dependencies +# RUN rustup target add x86_64-unknown-linux-musl + +# Cross-compiling for musl requires some specific linkers due to ring +# https://github.com/briansmith/ring/issues/1414#issuecomment-1055177218 +# RUN apt update && apt install -y musl-tools clang llvm musl-dev +# ENV RUSTFLAGS='-C linker=x86_64-linux-gnu-gcc' +# ENV CC_aarch64_unknown_linux_musl=clang +# ENV AR_aarch64_unknown_linux_musl=llvm-ar +# ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld" + WORKDIR /app COPY . . -RUN cargo build --release --bin atomic-server --config net.git-fetch-with-cli=true +RUN cargo build --release --bin atomic-server --config net.git-fetch-with-cli=true --target x86_64-unknown-linux-musl +RUN strip -s /app/target/x86_64-unknown-linux-musl/release/atomic-server + +FROM scratch as runtime +COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/atomic-server /atomic-server-bin -# We only need a small runtime for this step, but make sure glibc is installed -FROM frolvlad/alpine-glibc:alpine-3.16_glibc-2.34 as runtime -COPY --chmod=0755 --from=builder /app/target/release/atomic-server /atomic-server-bin # For a complete list of possible ENV vars or available flags, run with `--help` ENV ATOMIC_STORE_PATH="/atomic-storage/db" ENV ATOMIC_CONFIG_PATH="/atomic-storage/config.toml"