summaryrefslogtreecommitdiff
path: root/Dockerfile
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2022-01-15 12:08:20 +0300
committerValery Piashchynski <[email protected]>2022-01-15 12:08:20 +0300
commit5254c8eb27311e2a8a53a4c90c3829cf1238c563 (patch)
treeb51c9a4c1dd4c25adc511498ce0380a7078c5572 /Dockerfile
parent13609dd03dd0d2fa85b9fb850be787bf4e2ea67f (diff)
Repository content update
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile47
1 files changed, 47 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..ac4981bf
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,47 @@
+# Image page: <https://hub.docker.com/_/golang>
+FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:alpine 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"
+
+COPY . /src
+
+WORKDIR /src
+
+# arguments to pass on each go tool link invocation
+ENV LDFLAGS="-s \
+-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=$APP_VERSION \
+-X github.com/spiral/roadrunner-binary/v2/internal/meta.buildTime=$BUILD_TIME"
+
+# compile binary file
+RUN set -x \
+ && CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" -o ./rr ./cmd/rr \
+ && ./rr -v
+
+# Image page: <https://hub.docker.com/_/alpine>
+# https://alpinelinux.org/posts/Alpine-3.13.4-released.html
+# Critical issue with 3.13.3 https://nvd.nist.gov/vuln/detail/CVE-2021-28831
+FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3
+
+# use same build arguments for image labels
+ARG APP_VERSION="undefined"
+ARG BUILD_TIME="undefined"
+
+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-binary" \
+ org.opencontainers.image.source="https://github.com/spiral/roadrunner-binary" \
+ 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"]