Skip to content

Commit f68e8e7

Browse files
authored
[infra] proposing detailed Multistage Dockerfile (#69)
* proposing detailed Multistage Dockerfile * removing leftovers
1 parent c1ee00d commit f68e8e7

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

Diff for: .dockerignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# git + GitHub stuff
2+
.git*
3+
*.yml
4+
5+
# Markdown
6+
README.md
7+
LICENSE.md
8+
9+
Dockerfile*
10+
Makefile

Diff for: Dockerfile

+14-6
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,28 @@
22
# Stage 1: Build
33
#===============
44

5-
FROM golang:1.21-alpine as builder
5+
FROM golang:1.22-alpine AS builder
66

7-
COPY . /app
7+
WORKDIR /src
88

9-
WORKDIR /app
9+
RUN --mount=type=cache,target=/go/pkg/mod/ \
10+
--mount=type=cache,target=/root/.cache/go-build \
11+
--mount=type=bind,source=go.sum,target=go.sum \
12+
--mount=type=bind,source=go.mod,target=go.mod \
13+
go mod download -x
1014

11-
RUN go build -o indexer ./cmd
15+
ENV CGO_ENABLED=0 GOOS=linux
16+
17+
RUN --mount=type=cache,target=/go/pkg/mod/ \
18+
--mount=type=cache,target=/root/.cache/go-build \
19+
--mount=type=bind,target=. \
20+
go build -o /app/indexer ./cmd
1221

1322
#===============
1423
# Stage 2: Run
1524
#===============
1625

17-
FROM alpine
26+
FROM alpine:3.20 AS tx-indexer
1827

1928
COPY --from=builder /app/indexer /usr/local/bin/indexer
20-
2129
ENTRYPOINT [ "/usr/local/bin/indexer" ]

Diff for: Dockerfile.release

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This Dockerfile is only useful for Goreleaser task
2+
# https://goreleaser.com/customization/docker/
13
FROM scratch
24
COPY tx-indexer /
35
ENTRYPOINT [ "/tx-indexer" ]

0 commit comments

Comments
 (0)