Skip to content

Commit bc29733

Browse files
committed
[3ad0f41] Update Dockerfiles and .goreleaser.yml
1 parent 09209bb commit bc29733

File tree

4 files changed

+91
-8
lines changed

4 files changed

+91
-8
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Dockerfile*
2+
.*ignore

.goreleaser.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ brews:
6868
- name: govc
6969
ids:
7070
- govc
71-
github:
71+
tap:
7272
owner: govmomi
7373
name: homebrew-tap
7474
commit_author:
@@ -84,7 +84,7 @@ brews:
8484
- name: vcsim
8585
ids:
8686
- vcsim
87-
github:
87+
tap:
8888
owner: govmomi
8989
name: homebrew-tap
9090
commit_author:

Dockerfile.govc

+42-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
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
124
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"]

Dockerfile.vcsim

+45-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
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
124
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"]

0 commit comments

Comments
 (0)