File tree Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ name : dockerfile
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ tags :
7+ - ' v*'
8+ pull_request :
9+ branches : [ master ]
10+
11+ jobs :
12+ dockerfile :
13+ name : Run Dockerfiles in examples
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v2
17+
18+ - name : Run example - simple
19+ run : |
20+ cd ./_example/simple
21+ docker build -t simple .
22+ docker run simple | grep 99\ こんにちわ世界099
Original file line number Diff line number Diff line change 1+ # =============================================================================
2+ # Multi-stage Dockerfile Example
3+ # =============================================================================
4+ # This is a simple Dockerfile that will build an image of scratch-base image.
5+ # Usage:
6+ # docker build -t simple:local . && docker run --rm simple:local
7+ # =============================================================================
8+
9+ # -----------------------------------------------------------------------------
10+ # Build Stage
11+ # -----------------------------------------------------------------------------
12+ FROM golang:alpine AS build
13+
14+ # Important:
15+ # Because this is a CGO enabled package, you are required to set it as 1.
16+ ENV CGO_ENABLED=1
17+
18+ RUN apk add --no-cache \
19+ # Important: required for go-sqlite3
20+ gcc \
21+ # Required for Alpine
22+ musl-dev
23+
24+ WORKDIR /workspace
25+
26+ COPY . /workspace/
27+
28+ RUN \
29+ go mod init github.com/mattn/sample && \
30+ go mod tidy && \
31+ go install -ldflags="-s -w -extldflags \" -static\" " ./simple.go
32+
33+ RUN \
34+ # Smoke test
35+ set -o pipefail; \
36+ /go/bin/simple | grep 99\ こんにちわ世界099
37+
38+ # -----------------------------------------------------------------------------
39+ # Main Stage
40+ # -----------------------------------------------------------------------------
41+ FROM scratch
42+
43+ COPY --from=build /go/bin/simple /usr/local/bin/simple
44+
45+ ENTRYPOINT [ "/usr/local/bin/simple" ]
You can’t perform that action at this time.
0 commit comments