Skip to content

Commit 781848d

Browse files
Update Dockerfile_next (#1773)
1 parent 27afe9b commit 781848d

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

Dockerfile_next

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,53 @@
1-
FROM golang:1.22.4 as builder
1+
# Stage 1: Builder
2+
FROM golang:1.22.4 AS builder
3+
4+
# Build arguments
25
ARG COMMIT_SHA
3-
RUN echo "commit sha: ${COMMIT_SHA}"
6+
RUN echo "Commit SHA: ${COMMIT_SHA}"
47

58
# Set the working directory
69
WORKDIR $GOPATH/src/github.com/diggerhq/digger
710

8-
# Copy all required source, blacklist files that are not required through `.dockerignore`
9-
COPY . .
10-
11-
# Get the vendor library
12-
RUN go version
13-
14-
# RUN vgo install
11+
# Cache Go dependencies by copying only the go.mod and go.sum files
12+
COPY go.mod go.sum ./
13+
RUN go mod download
1514

16-
# https://github.com/ethereum/go-ethereum/issues/2738
17-
# Build static binary "-getmode=vendor" does not work with go-ethereum
15+
# Copy the rest of the application code
16+
COPY . .
1817

18+
# Build the static binary
1919
RUN go build -ldflags="-X 'main.Version=${COMMIT_SHA}'" -o next_exe ./next/
2020

21-
# Multi-stage build will just copy the binary to an alpine image.
22-
FROM ubuntu:24.04 as runner
23-
ENV ATLAS_VERSION v0.28.0
21+
# Stage 2: Runner
22+
FROM ubuntu:24.04-slim AS runner
23+
ENV ATLAS_VERSION v0.16.0
2424
ARG COMMIT_SHA
2525
WORKDIR /app
2626

27-
RUN apt-get update && apt-get install -y ca-certificates curl && apt-get install -y git && apt-get clean all
28-
RUN update-ca-certificates
27+
# Install necessary packages and clean up in a single step
28+
RUN apt-get update && \
29+
apt-get install -y --no-install-recommends \
30+
ca-certificates curl git && \
31+
rm -rf /var/lib/apt/lists/* && \
32+
update-ca-certificates
2933

30-
RUN echo "commit sha: ${COMMIT_SHA}"
34+
# Print commit SHA
35+
RUN echo "Commit SHA: ${COMMIT_SHA}"
3136

32-
# install atlas
37+
# Install Atlas
3338
RUN curl -sSf https://atlasgo.sh | sh
3439

35-
36-
37-
# Set gin to production
3840
#ENV GIN_MODE=release
3941

4042
# Expose the running port
4143
EXPOSE 3000
4244

43-
# Copy the binary to the corresponding folder
45+
# Copy binary and entrypoint
4446
COPY --from=builder /go/src/github.com/diggerhq/digger/next_exe /app/next
4547
COPY --from=builder /go/src/github.com/diggerhq/digger/next/scripts/entrypoint.sh /app/entrypoint.sh
4648
ADD next/templates ./templates
4749

48-
# Run the binary
50+
# Set entrypoint and permissions
51+
RUN chmod +x /app/entrypoint.sh
4952
ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh"]
53+

0 commit comments

Comments
 (0)