This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 201
Use alpine docker file #1
Open
justgage
wants to merge
4
commits into
apilayer:master
Choose a base branch
from
justgage:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
FROM golang:1.9 | ||
FROM golang:1.9-alpine | ||
|
||
RUN apk add --no-cache git libcap shadow | ||
RUN useradd -ms /bin/bash freegeoip | ||
COPY cmd/freegeoip/public /var/www | ||
|
||
ADD . /go/src/github.com/apilayer/freegeoip | ||
WORKDIR /go/src/github.com/apilayer/freegeoip/cmd/freegeoip | ||
RUN \ | ||
cd /go/src/github.com/apilayer/freegeoip/cmd/freegeoip && \ | ||
go get -d && go install && \ | ||
apt-get update && apt-get install -y libcap2-bin && \ | ||
setcap cap_net_bind_service=+ep /go/bin/freegeoip && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* && \ | ||
useradd -ms /bin/bash freegeoip | ||
go get -d && \ | ||
go install && \ | ||
setcap cap_net_bind_service=+ep /go/bin/freegeoip | ||
|
||
USER freegeoip | ||
ENTRYPOINT ["/go/bin/freegeoip"] | ||
USER freegeoip | ||
|
||
EXPOSE 8080 | ||
|
||
# CMD instructions: | ||
# Add "-use-x-forwarded-for" if your server is behind a reverse proxy | ||
# Add "-public", "/var/www" to enable the web front-end | ||
# Add "-internal-server", "8888" to enable the pprof+metrics server | ||
# | ||
# Example: | ||
# CMD ["-use-x-forwarded-for", "-public", "/var/www", "-internal-server", "8888"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted these comments because I don't think they were bringing much value, however I can put them back due to that being outside the scope of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justgage there is a great Dockerfile best practices article here. I thought I would pass it along.
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
Following these recommendations, specifically for RUN, it will create a more readable Dockerfile:
Notice that the ADD was changed to a COPY as per the recommendation here on transparency.