diff --git a/.dockerignore b/.dockerignore index 44afaad418..5b283cec1e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,14 +1,12 @@ * -!target/x86_64-unknown-linux-musl/release/server -!target/x86_64-unknown-linux-musl/release/server_supervisor -!target/x86_64-unknown-linux-musl/release/plonk_step_by_step_prover -!target/x86_64-unknown-linux-musl/release/dummy_prover -!target/x86_64-unknown-linux-musl/release/dev-ticker-server !docker/prover/prover-entry.sh !docker/keybase-secrets/entrypoint.sh !keys/packed !docker/nginx/nginx.conf !bin/ +!core/ +!Cargo.lock +!Cargo.toml !contracts/build !js/client/index.html !js/client/dist diff --git a/.github/workflows/promote-stage.yml b/.github/workflows/promote-stage.yml index a20ae25481..88c8b86638 100644 --- a/.github/workflows/promote-stage.yml +++ b/.github/workflows/promote-stage.yml @@ -11,17 +11,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Get env from keybase - uses: ./.github/actions/keybase-secrets - with: - repo: keybase://team/matter_labs/zk-secret - env: - KEYBASE_PAPERKEY: ${{ secrets.KEYBASE_PAPERKEY }} - KEYBASE_USERNAME: ${{ secrets.KEYBASE_USERNAME }} - - - name: restore-selfhosted-runner-cache - run: tar xf ~/runner-cache.tar - - name: setup-env run: | echo "::set-env name=ZKSYNC_HOME::$(pwd)" @@ -39,3 +28,13 @@ jobs: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} zksync update-images echo "::set-env name=IMAGE_TAG::$(f sh -c 'echo $IMAGE_TAG')" + + - name: promote-to-gitlab + run: | + curl -X POST \ + -F token=${{ secrets.GITLAB_TOKEN }} \ + -F "ref=gitlab-deploy" \ + -F "variables[SERVER_TAG]=$IMAGE_TAG" \ + -F "variables[PROVER_TAG]=$IMAGE_TAG" \ + -F "variables[EXPLORER_TAG]=$IMAGE_TAG" \ + https://gitlab.com/api/v4/projects/19165314/trigger/pipeline \ No newline at end of file diff --git a/Makefile b/Makefile index d4f74695b8..8b8b29e984 100644 --- a/Makefile +++ b/Makefile @@ -113,11 +113,6 @@ image-keybase: push-image-keybase: image-keybase docker push "${KEYBASE_DOCKER_IMAGE}" -# Using RUST+Linux docker image (ekidd/rust-musl-builder) to build for Linux. More at https://github.com/emk/rust-musl-builder -docker-options = --rm -v $(shell pwd):/home/rust/src -v cargo-git:/home/rust/.cargo/git -v cargo-registry:/home/rust/.cargo/registry --env-file $(ZKSYNC_HOME)/etc/env/$(ZKSYNC_ENV).env -rust-musl-builder = @docker run $(docker-options) ekidd/rust-musl-builder - - # Rust: main stuff server: @@ -126,19 +121,11 @@ server: sandbox: @cargo run --bin sandbox -# See more more at https://github.com/emk/rust-musl-builder#caching-builds -build-target: build-contracts - $(rust-musl-builder) sudo chown -R rust:rust /home/rust/src /home/rust/.cargo/git /home/rust/.cargo/registry - $(rust-musl-builder) cargo build --release - -clean-target: - $(rust-musl-builder) cargo clean - -image-server: build-target - @docker build -t "${SERVER_DOCKER_IMAGE}" -t "${SERVER_DOCKER_IMAGE_LATEST}" -f ./docker/server/Dockerfile . +image-server: build-contracts + @DOCKER_BUILDKIT=1 docker build -t "${SERVER_DOCKER_IMAGE}" -t "${SERVER_DOCKER_IMAGE_LATEST}" -f ./docker/server/Dockerfile . -image-prover: build-target - @docker build -t "${PROVER_DOCKER_IMAGE}" -t "${PROVER_DOCKER_IMAGE_LATEST}" -f ./docker/prover/Dockerfile . +image-prover: build-contracts + @DOCKER_BUILDKIT=1 docker build -t "${PROVER_DOCKER_IMAGE}" -t "${PROVER_DOCKER_IMAGE_LATEST}" -f ./docker/prover/Dockerfile . image-rust: image-server image-prover @@ -289,7 +276,7 @@ dev-build-geth: dev-push-geth: @docker push "${GETH_DOCKER_IMAGE}" -image-dev-ticker: build-target +image-dev-ticker: @docker build -t "${DEV_TICKER_DOCKER_IMAGE}" -f ./docker/dev-ticker/Dockerfile . push-image-dev-ticker: image-dev-ticker diff --git a/docker/dev-ticker/Dockerfile b/docker/dev-ticker/Dockerfile index 64be55f48d..4e85daa423 100644 --- a/docker/dev-ticker/Dockerfile +++ b/docker/dev-ticker/Dockerfile @@ -1,5 +1,16 @@ -FROM alpine +# syntax=docker/dockerfile:experimental +FROM rust:1.45 as builder +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + cargo install sccache +WORKDIR /usr/src/zksync +COPY . . +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ + RUSTC_WRAPPER=/usr/local/cargo/bin/sccache \ + cargo build --release + +FROM debian:buster-slim EXPOSE 9876 ENV RUST_LOG info -COPY target/x86_64-unknown-linux-musl/release/dev-ticker-server /bin/ +COPY --from=builder /usr/src/zksync/target/release/dev-ticker-server /bin/ ENTRYPOINT ["dev-ticker-server"] diff --git a/docker/prover/Dockerfile b/docker/prover/Dockerfile index d0e4383c56..60f490a3a4 100644 --- a/docker/prover/Dockerfile +++ b/docker/prover/Dockerfile @@ -1,4 +1,16 @@ -FROM alpine +# syntax=docker/dockerfile:experimental +FROM rust:1.45 as builder +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + cargo install sccache +WORKDIR /usr/src/zksync +COPY . . +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ + RUSTC_WRAPPER=/usr/local/cargo/bin/sccache \ + cargo build --release + +FROM debian:buster-slim +RUN apt-get update && apt-get install -y axel && rm -rf /var/lib/apt/lists/* # Docs of env variables used for this image # to test this locally just run # docker build -t tmp_prover -f =(f envsubst < ./docker/prover/Dockerfile) .; docker run --rm tmp_prover:latest @@ -19,14 +31,13 @@ FROM alpine #ENV PROVER_CYCLE_WAIT $PROVER_CYCLE_WAIT #ENV PROVER_GONE_TIMEOUT $PROVER_GONE_TIMEOUT #ENV DOCKER_DUMMY_PROVER $DOCKER_DUMMY_PROVER -COPY target/x86_64-unknown-linux-musl/release/plonk_step_by_step_prover /bin/ -COPY target/x86_64-unknown-linux-musl/release/dummy_prover /bin/ +COPY --from=builder /usr/src/zksync/target/release/plonk_step_by_step_prover /bin/ +COPY --from=builder /usr/src/zksync/target/release/dummy_prover /bin/ COPY docker/prover/prover-entry.sh /bin/ COPY bin/plonk-setup /bin/ COPY bin/verify-keys /bin/ COPY bin/utils.sh /bin/ COPY keys/packed /keys/packed COPY contracts/build/ /contracts/build/ -RUN apk add --no-cache axel curl bash CMD ["prover-entry.sh"] diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile index dc231c67d1..6eb8a395ae 100644 --- a/docker/server/Dockerfile +++ b/docker/server/Dockerfile @@ -1,8 +1,20 @@ -FROM alpine +# syntax=docker/dockerfile:experimental +FROM rust:1.45 as builder +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + cargo install sccache +WORKDIR /usr/src/zksync +COPY . . +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/root/.cache/sccache \ + RUSTC_WRAPPER=/usr/local/cargo/bin/sccache \ + cargo build --release + +FROM debian:buster-slim +RUN apt-get update && apt-get install -y libpq5 && rm -rf /var/lib/apt/lists/* EXPOSE 3000 EXPOSE 3031 EXPOSE 3030 -COPY target/x86_64-unknown-linux-musl/release/server / +COPY --from=builder /usr/src/zksync/target/release/server /usr/bin COPY contracts/build/ /contracts/build/ COPY bin/kube-is-leader.sh /bin/ -ENTRYPOINT ["/server"] +ENTRYPOINT ["server"] \ No newline at end of file