summaryrefslogtreecommitdiff
path: root/Dockerfile
blob: 14df4924d1db5f9c0dc95f6c0021dbf2c5f8f2ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Image page: <https://hub.docker.com/_/golang>
FROM golang:1.15.7 as builder

# app version and build date must be passed during image building (version without any prefix).
# e.g.: `docker build --build-arg "APP_VERSION=1.2.3" --build-arg "BUILD_TIME=$(date +%FT%T%z)" .`
ARG APP_VERSION="undefined"
ARG BUILD_TIME="undefined"

# arguments to pass on each go tool link invocation
ENV LDFLAGS="-s \
-X github.com/spiral/roadrunner/v2/cmd/cli.Version=$APP_VERSION \
-X github.com/spiral/roadrunner/v2/cmd/cli.BuildTime=$BUILD_TIME"

RUN mkdir /src

WORKDIR /src
RUN mkdir -p /src/cli

COPY cmd/go.mod ./
COPY cmd/go.sum ./
COPY cmd/main.go ./
COPY cmd/cli/* /src/cli/
COPY .rr.yaml ./

# Burn modules cache
RUN set -x \
    && go version \
    && go mod download \
    && go mod verify

# compile binary file
RUN CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" -o rr main.go

# Image page: <https://hub.docker.com/_/alpine>
FROM alpine:3.13

# use same build arguments for image labels
ARG APP_VERSION
ARG BUILD_TIME

LABEL \
    org.opencontainers.image.title="roadrunner" \
    org.opencontainers.image.description="High-performance PHP application server, load-balancer and process manager" \
    org.opencontainers.image.url="https://github.com/spiral/roadrunner" \
    org.opencontainers.image.source="https://github.com/spiral/roadrunner" \
    org.opencontainers.image.vendor="SpiralScout" \
    org.opencontainers.image.version="$APP_VERSION" \
    org.opencontainers.image.created="$BUILD_TIME" \
    org.opencontainers.image.licenses="MIT"

# copy required files from builder image
COPY --from=builder /src/rr /usr/bin/rr
COPY --from=builder /src/.rr.yaml /etc/rr.yaml

# use roadrunner binary as image entrypoint
ENTRYPOINT ["/usr/bin/rr"]