chore(docker): run as non root user in container (#727)
This commit is contained in:
parent
5a8b7afa28
commit
7c039f9b37
|
@ -2,17 +2,24 @@ FROM alpine:3.17
|
||||||
|
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
ARG USER=gorush
|
||||||
|
ENV HOME /home/$USER
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||||
org.label-schema.name="Gorush" \
|
org.label-schema.name="Gorush" \
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
org.label-schema.vendor="Bo-Yi Wu" \
|
||||||
org.label-schema.schema-version="1.0"
|
org.label-schema.schema-version="1.0"
|
||||||
|
|
||||||
|
# add new user
|
||||||
|
RUN adduser -D $USER
|
||||||
RUN apk add --no-cache ca-certificates mailcap && \
|
RUN apk add --no-cache ca-certificates mailcap && \
|
||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
COPY release/${TARGETOS}/${TARGETARCH}/gorush /bin/
|
COPY release/${TARGETOS}/${TARGETARCH}/gorush /bin/
|
||||||
|
|
||||||
|
USER $USER
|
||||||
|
WORKDIR $HOME
|
||||||
|
|
||||||
EXPOSE 8088 9000
|
EXPOSE 8088 9000
|
||||||
HEALTHCHECK --start-period=1s --interval=10s --timeout=5s \
|
HEALTHCHECK --start-period=1s --interval=10s --timeout=5s \
|
||||||
CMD ["/bin/gorush", "--ping"]
|
CMD ["/bin/gorush", "--ping"]
|
||||||
|
|
|
@ -29,9 +29,13 @@ func GetVersion() string {
|
||||||
|
|
||||||
// PrintGoRushVersion provide print server engine
|
// PrintGoRushVersion provide print server engine
|
||||||
func PrintGoRushVersion() {
|
func PrintGoRushVersion() {
|
||||||
|
if len(commit) > 7 {
|
||||||
|
commit = commit[:7]
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf(`GoRush %s, Commit: %s, Compiler: %s %s, Copyright (C) 2023 Bo-Yi Wu, Inc.`,
|
fmt.Printf(`GoRush %s, Commit: %s, Compiler: %s %s, Copyright (C) 2023 Bo-Yi Wu, Inc.`,
|
||||||
version,
|
version,
|
||||||
commit[:7],
|
commit,
|
||||||
runtime.Compiler,
|
runtime.Compiler,
|
||||||
runtime.Version())
|
runtime.Version())
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
Loading…
Reference in New Issue