1
- # Use a multi-stage build for efficiency
2
- FROM golang:1.22 AS go-builder
1
+ # Build stage
2
+ FROM --platform=$BUILDPLATFORM golang:1.22-alpine AS builder
3
+
4
+ # Install build dependencies
5
+ RUN apk add --no-cache make gcc musl-dev linux-headers git
6
+
7
+ # Set up cross-compilation
8
+ ARG TARGETOS
9
+ ARG TARGETARCH
10
+ ENV GOOS=$TARGETOS
11
+ ENV GOARCH=$TARGETARCH
12
+
13
+ # Install cross-compilation tools for ARM64
14
+ RUN if [ "$TARGETARCH" = "arm64" ]; then \
15
+ apk add --no-cache gcc-aarch64-none-elf musl-dev; \
16
+ fi
3
17
4
- # Set up Go environment
5
- FROM go-builder AS optimism-builder
6
18
WORKDIR /optimism
7
19
8
20
# Cache go modules
@@ -15,32 +27,19 @@ COPY ./proposer/op /optimism/op-proposer
15
27
WORKDIR /optimism/op-proposer/proposer
16
28
RUN --mount=type=cache,target=/root/.cache/go-build \
17
29
make op-proposer
18
- RUN ls -l /optimism/op-proposer/proposer
19
- RUN ls -l /optimism/op-proposer/proposer/bin
20
- RUN pwd
21
30
22
- # Use a slim Debian image for the final stage
23
- FROM ubuntu:22.04
31
+ # Runtime stage
32
+ FROM --platform=$TARGETPLATFORM ubuntu:22.04
24
33
25
- # Install necessary dependencies
26
- RUN --mount=type=cache,target=/var/cache/apt \
27
- apt-get update && apt-get install -y \
34
+ RUN apt-get update && apt-get install -y \
28
35
ca-certificates \
29
36
sqlite3 \
30
37
&& rm -rf /var/lib/apt/lists/*
31
38
32
- # Copy the built op-proposer binary from the previous stage
33
- COPY --from=optimism-builder /optimism/op-proposer/proposer/bin/op-proposer /usr/local/bin/op-proposer
34
-
35
- # Set the entrypoint to run op-proposer with environment variables
36
- COPY ./proposer/op/op_proposer.sh /usr/local/bin/op_proposer.sh
37
-
38
- # Copy the rollup configs
39
+ COPY --from=builder /optimism/op-proposer/proposer/bin/op-proposer /usr/local/bin/
40
+ COPY ./proposer/op/op_proposer.sh /usr/local/bin/
39
41
COPY ../configs /configs
40
42
41
- # Make the binary and entrypoint executable.
42
- RUN ls -l /usr/local/bin/
43
- RUN chmod +x /usr/local/bin/op-proposer
44
- RUN chmod +x /usr/local/bin/op_proposer.sh
43
+ RUN chmod +x /usr/local/bin/op-proposer /usr/local/bin/op_proposer.sh
45
44
46
45
ENTRYPOINT ["/usr/local/bin/op_proposer.sh"]
0 commit comments