Skip to content

Commit

Permalink
[infra] proposing detailed Multistage Dockerfile (#69)
Browse files Browse the repository at this point in the history
* proposing detailed Multistage Dockerfile

* removing leftovers
  • Loading branch information
sw360cab authored Aug 13, 2024
1 parent c1ee00d commit f68e8e7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# git + GitHub stuff
.git*
*.yml

# Markdown
README.md
LICENSE.md

Dockerfile*
Makefile
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@
# Stage 1: Build
#===============

FROM golang:1.21-alpine as builder
FROM golang:1.22-alpine AS builder

COPY . /app
WORKDIR /src

WORKDIR /app
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x

RUN go build -o indexer ./cmd
ENV CGO_ENABLED=0 GOOS=linux

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,target=. \
go build -o /app/indexer ./cmd

#===============
# Stage 2: Run
#===============

FROM alpine
FROM alpine:3.20 AS tx-indexer

COPY --from=builder /app/indexer /usr/local/bin/indexer

ENTRYPOINT [ "/usr/local/bin/indexer" ]
2 changes: 2 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This Dockerfile is only useful for Goreleaser task
# https://goreleaser.com/customization/docker/
FROM scratch
COPY tx-indexer /
ENTRYPOINT [ "/tx-indexer" ]
Expand Down

0 comments on commit f68e8e7

Please sign in to comment.