File tree 4 files changed +91
-8
lines changed
4 files changed +91
-8
lines changed Original file line number Diff line number Diff line change
1
+ Dockerfile *
2
+ . * ignore
Original file line number Diff line number Diff line change 68
68
- name : govc
69
69
ids :
70
70
- govc
71
- github :
71
+ tap :
72
72
owner : govmomi
73
73
name : homebrew-tap
74
74
commit_author :
84
84
- name : vcsim
85
85
ids :
86
86
- vcsim
87
- github :
87
+ tap :
88
88
owner : govmomi
89
89
name : homebrew-tap
90
90
commit_author :
Original file line number Diff line number Diff line change
1
+ # Create a builder container
2
+ # golang:1.16.0-buster amd64
3
+ FROM golang@sha256:f254180c5defa2653955e963fb0626e3d4fbbb162f7cff6490e94607d1d867ff AS build
4
+ WORKDIR /go/src/app
5
+
6
+ # Create appuser to isolate potential vulnerabilities
7
+ # See https://stackoverflow.com/a/55757473/12429735
8
+ ENV USER=appuser
9
+ ENV UID=10001
10
+ RUN adduser \
11
+ --disabled-password \
12
+ --gecos "" \
13
+ --home "/nonexistent" \
14
+ --shell "/sbin/nologin" \
15
+ --no-create-home \
16
+ --uid "${UID}" \
17
+ "${USER}"
18
+
19
+ # Create a new tmp directory so no bad actors can manipulate it
20
+ RUN mkdir /temporary-tmp-directory && chmod 777 /temporary-tmp-directory
21
+
22
+ ###############################################################################
23
+ # Final stage
1
24
FROM scratch
2
- LABEL maintainer="
[email protected] "
3
- COPY govc /
4
- ENTRYPOINT [ "/govc" ]
25
+
26
+ # Run all commands as non-root
27
+ USER appuser:appuser
28
+
29
+ # Allow container to use latest TLS certificates
30
+ COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
31
+
32
+ # Copy over appuser to run as non-root
33
+ COPY --from=build /etc/passwd /etc/passwd
34
+ COPY --from=build /etc/group /etc/group
35
+
36
+ # Copy over the /tmp directory for golang/os.TmpDir
37
+ COPY --chown=appuser --from=build /temporary-tmp-directory /tmp
38
+
39
+ # Copy application from external build
40
+ COPY govc /govc
41
+
42
+ # Set CMD to application with container defaults
43
+ CMD ["/govc"]
Original file line number Diff line number Diff line change
1
+ # Create a builder container
2
+ # golang:1.16.0-buster amd64
3
+ FROM golang@sha256:f254180c5defa2653955e963fb0626e3d4fbbb162f7cff6490e94607d1d867ff AS build
4
+ WORKDIR /go/src/app
5
+
6
+ # Create appuser to isolate potential vulnerabilities
7
+ # See https://stackoverflow.com/a/55757473/12429735
8
+ ENV USER=appuser
9
+ ENV UID=10001
10
+ RUN adduser \
11
+ --disabled-password \
12
+ --gecos "" \
13
+ --home "/nonexistent" \
14
+ --shell "/sbin/nologin" \
15
+ --no-create-home \
16
+ --uid "${UID}" \
17
+ "${USER}"
18
+
19
+ # Create a new tmp directory so no bad actors can manipulate it
20
+ RUN mkdir /temporary-tmp-directory && chmod 777 /temporary-tmp-directory
21
+
22
+ ###############################################################################
23
+ # Final stage
1
24
FROM scratch
2
- LABEL maintainer="
[email protected] "
3
- COPY vcsim /
4
- ENTRYPOINT [ "/vcsim" ]
25
+
26
+ # Run all commands as non-root
27
+ USER appuser:appuser
28
+
29
+ # Allow container to use latest TLS certificates
30
+ COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
31
+
32
+ # Copy over appuser to run as non-root
33
+ COPY --from=build /etc/passwd /etc/passwd
34
+ COPY --from=build /etc/group /etc/group
35
+
36
+ # Copy over the /tmp directory for golang/os.TmpDir
37
+ COPY --chown=appuser --from=build /temporary-tmp-directory /tmp
38
+
39
+ # Expose application port
40
+ EXPOSE 8989
41
+
42
+ # Copy application from external build
43
+ COPY vcsim /vcsim
44
+
45
+ # Set entrypoint to application with container defaults
46
+ ENTRYPOINT ["/vcsim", "-l", "0.0.0.0:8989"]
You can’t perform that action at this time.
0 commit comments