Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit c6bf318

Browse files
committed
Fix: enables CGo to allow Go to use C libs
1 parent 277f98d commit c6bf318

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

Dockerfile

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,32 @@
11
# Build stage
2-
FROM golang:1.22 as builder
2+
FROM golang:1.22 AS builder
33

4-
# Set working directory
5-
WORKDIR /tmp
4+
# Set necessary environment variables
5+
ENV CGO_ENABLED=1
6+
ENV GOOS=linux
7+
ENV GOARCH=amd64
68

7-
# Install dependencies
8-
#RUN apk add --no-cache make gcc musl-dev linux-headers git
9-
RUN apt-get update && apt-get install -y git musl-dev make
9+
WORKDIR /tmp
1010

11-
# Clean the Go module cache
12-
RUN go clean -modcache
11+
RUN apt-get update && apt-get install -y --no-install-recommends make gcc g++ musl-dev git && rm -rf /var/lib/apt/lists/*
1312

14-
# Clone the specific branch of the Sonic repository and build the application
1513
RUN git clone --depth 1 --branch v1.2.1-f https://github.com/Fantom-foundation/Sonic.git && \
1614
cd Sonic && \
1715
make all
1816

1917
# Final stage
20-
FROM alpine:latest
2118

22-
# Set working directory
19+
FROM ubuntu:22.04
20+
2321
WORKDIR /root/.sonic
2422

25-
# Install ca-certificates for HTTPS
26-
RUN apk add --no-cache ca-certificates curl jq
23+
# Install runtime dependencies, including glibc
24+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl jq && rm -rf /var/lib/apt/lists/*
2725

2826
# Copy binaries from builder stage
29-
COPY --from=builder /tmp/Sonic/build/sonicd /usr/local/bin/
30-
COPY --from=builder /tmp/Sonic/build/sonictool /usr/local/bin/
31-
32-
# Create a non-root user
33-
RUN adduser -D -u 1000 sonic
34-
35-
# Switch to non-root user
36-
USER sonic
27+
COPY --from=builder /tmp/Sonic/build/ /usr/local/bin
3728

38-
# Expose necessary ports
39-
EXPOSE 5050 5050/udp 80 18546 18545
29+
# Expose Sonic's default ports (change if necessary)
30+
EXPOSE 18545 18546
4031

41-
# Set the entrypoint (default to running sonicd, but can be overridden)
42-
ENTRYPOINT ["sonicd"]
32+
ENTRYPOINT ["sonicd"]

0 commit comments

Comments
 (0)