Skip to content

Commit

Permalink
feat: add go binary to Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
torives committed Oct 2, 2023
1 parent 979c8ea commit e6780e0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
# syntax=docker.io/docker/dockerfile:1.4

ARG RUST_VERSION=1.72.1
ARG GO_VERSION=1.21.1
ARG SERVER_MANAGER_VERSION=0.8.2
ARG ROLLUPS_CONTRACTS_VERSION=1.0.2

ARG BASE_PATH=/opt/cartesi
ARG RUST_BUILD_PATH=${BASE_PATH}/src/rollups-node/offchain
ARG DEPLOYMENT_PATH=${BASE_PATH}/share/deployments
ARG GO_BASE_PATH=/go
ARG GO_BUILD_PATH=${GO_BASE_PATH}/rollups-node
ARG GO_BIN_PATH=${GO_BASE_PATH}/bin
ARG RUNTIME_DIR=/var/opt/cartesi

#
Expand Down Expand Up @@ -67,6 +71,15 @@ RUN cargo chef cook --release --recipe-path recipe.json
COPY ./offchain/ .
RUN cargo build --release

#
# Go build
#
FROM golang:${GO_VERSION}-bookworm as go-builder
ARG GO_BUILD_PATH
WORKDIR ${GO_BUILD_PATH}
COPY . .
RUN go install -ldflags "-s -w" ./cmd/cartesi-node

#
# Runtime
#
Expand All @@ -91,11 +104,15 @@ ARG RUST_BUILD_PATH
COPY --from=rust-builder ${RUST_BUILD_PATH}/target/release/cartesi-rollups-* .
ENV PATH="${BASE_PATH}/bin:${PATH}"

# Copy Go binary
ARG GO_BIN_PATH
COPY --from=go-builder ${GO_BIN_PATH}/cartesi-node .

# Setup runtime dir
ARG RUNTIME_DIR
RUN mkdir -p ${RUNTIME_DIR}
RUN chown cartesi:cartesi ${RUNTIME_DIR}
WORKDIR ${RUNTIME_DIR}

USER cartesi
# USER cartesi
CMD ["/bin/bash"]

0 comments on commit e6780e0

Please sign in to comment.