forked from hashicorp/waypoint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
83 lines (60 loc) · 2.67 KB
/
Dockerfile
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# syntax = docker.mirror.hashicorp.services/docker/dockerfile:experimental
#--------------------------------------------------------------------
# builder builds the Waypoint binaries
#--------------------------------------------------------------------
FROM docker.mirror.hashicorp.services/golang:1.16.5-alpine3.13 AS builder
RUN apk add --no-cache git gcc libc-dev make
RUN mkdir -p /tmp/wp-prime
COPY go.sum /tmp/wp-prime
COPY go.mod /tmp/wp-prime
WORKDIR /tmp/wp-prime
RUN go mod download
RUN go get github.com/kevinburke/go-bindata/...
COPY . /tmp/wp-src
WORKDIR /tmp/wp-src
RUN --mount=type=cache,target=/root/.cache/go-build make bin
RUN --mount=type=cache,target=/root/.cache/go-build make bin/entrypoint
# This is only used by ODR
FROM docker.mirror.hashicorp.services/busybox:stable-musl as busybox
RUN touch /tmp/.keep
#--------------------------------------------------------------------
# odr image
#--------------------------------------------------------------------
# This target is explicitly invoked from the command line, it's not used
# by the non-odr stages.
FROM gcr.io/kaniko-project/executor:latest as odr
COPY --from=builder /tmp/wp-src/waypoint /kaniko/waypoint
COPY --from=busybox /bin/busybox /kaniko/busybox
COPY --from=busybox /tmp /kaniko/tmp
# We add busybox and populate it with the tool links to make the image
# easier to use (having a shell, basic tools, etc)
RUN ["/kaniko/busybox", "mkdir", "/kaniko/bin"]
RUN ["/kaniko/busybox", "--install", "-s", "/kaniko/bin"]
# Need to add the dir with our tools in PATH
ENV PATH $PATH:/kaniko/bin
ENV TMPDIR /kaniko/tmp
ENTRYPOINT ["/kaniko/waypoint"]
#--------------------------------------------------------------------
# final image
#--------------------------------------------------------------------
FROM docker.mirror.hashicorp.services/alpine:3.13.5
# git is for gitrefpretty() and other calls for Waypoint
RUN apk add --no-cache git
COPY --from=builder /tmp/wp-src/waypoint /usr/bin/waypoint
COPY --from=builder /tmp/wp-src/waypoint-entrypoint /usr/bin/waypoint-entrypoint
VOLUME ["/data"]
# NOTE: userid must be 100 here. Otherwise upgrades will fail due to user not
# having the proper permissions to read the server db due to a different userid
RUN addgroup waypoint && \
adduser -S -u 100 -G waypoint waypoint && \
mkdir /data/ && \
chown -R waypoint:waypoint /data
# configure newuidmap/newgidmap to work with our waypoint user
RUN mkdir -p /run/user/100 \
&& chown -R waypoint /run/user/100 /home/waypoint \
&& echo waypoint:100000:65536 | tee /etc/subuid | tee /etc/subgid
USER waypoint
ENV USER waypoint
ENV HOME /home/waypoint
ENV XDG_RUNTIME_DIR=/run/user/100
ENTRYPOINT ["/usr/bin/waypoint"]