This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from nokia/nokia
Avoid granting Linux capabilities
- Loading branch information
Showing
5 changed files
with
38 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
FROM golang:1.7 | ||
|
||
RUN mkdir /app | ||
COPY . /go/src/github.com/microservices-demo/payment/ | ||
|
||
RUN go get -u github.com/FiloSottile/gvt | ||
RUN cd /go/src/github.com/microservices-demo/payment/ && gvt restore | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /app/main github.com/microservices-demo/payment/cmd/paymentsvc | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /app github.com/microservices-demo/payment/cmd/paymentsvc | ||
|
||
CMD ["/app/main", "-port=80"] | ||
FROM alpine:3.4 | ||
|
||
#EXPOSE 80 | ||
WORKDIR / | ||
COPY --from=0 /app /app | ||
|
||
ENV SERVICE_USER=myuser \ | ||
SERVICE_UID=10001 \ | ||
SERVICE_GROUP=mygroup \ | ||
SERVICE_GID=10001 | ||
|
||
RUN addgroup -g ${SERVICE_GID} ${SERVICE_GROUP} && \ | ||
adduser -g "${SERVICE_NAME} user" -D -H -G ${SERVICE_GROUP} -s /sbin/nologin -u ${SERVICE_UID} ${SERVICE_USER} && \ | ||
chmod +x /app && \ | ||
chown -R ${SERVICE_USER}:${SERVICE_GROUP} /app | ||
|
||
USER ${SERVICE_USER} | ||
|
||
CMD ["/app", "-port=8080"] | ||
|
||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
FROM alpine:3.4 | ||
|
||
WORKDIR / | ||
COPY app / | ||
|
||
ENV SERVICE_USER=myuser \ | ||
SERVICE_UID=10001 \ | ||
SERVICE_GROUP=mygroup \ | ||
SERVICE_GID=10001 | ||
|
||
RUN addgroup -g ${SERVICE_GID} ${SERVICE_GROUP} && \ | ||
adduser -g "${SERVICE_NAME} user" -D -H -G ${SERVICE_GROUP} -s /sbin/nologin -u ${SERVICE_UID} ${SERVICE_USER} && \ | ||
apk add --update libcap | ||
|
||
WORKDIR / | ||
EXPOSE 80 | ||
COPY app / | ||
|
||
RUN chmod +x /app && \ | ||
chown -R ${SERVICE_USER}:${SERVICE_GROUP} /app && \ | ||
setcap 'cap_net_bind_service=+ep' /app | ||
chmod +x /app && \ | ||
chown -R ${SERVICE_USER}:${SERVICE_GROUP} /app | ||
|
||
USER ${SERVICE_USER} | ||
|
||
CMD ["/app", "-port=80"] | ||
CMD ["/app", "-port=8080"] | ||
|
||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters