-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build a docker image for running ONCE - Part 2 #5014
Build a docker image for running ONCE - Part 2 #5014
Conversation
once/Dockerfile
Outdated
@@ -151,7 +151,7 @@ COPY ./custombuild/ ./custombuild/ | |||
# Let //go:embed to embed the built static files | |||
COPY --from=authgear-portal-stage-0 /usr/src/app/resources/authgear/ ./resources/authgear/ | |||
COPY --from=authgear-portal-stage-1 /usr/src/app/dist/ ./resources/portal/static/ | |||
RUN make build BIN_NAME=authgear-portal TARGET=portal GIT_HASH=$GIT_HASH | |||
RUN make build AUTHGEARONCE=1 BIN_NAME=authgear-portal TARGET=portal GIT_HASH=$GIT_HASH |
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 think this should be done by ARG
https://docs.docker.com/reference/dockerfile/#arg
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.
Since this is the Dockerfile to build once, AUTHGEARONCE should always be set. If it is a ARG, then it depends on the caller to set it correctly, which is no good.
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 have this comment because I saw this file is generated from the authgear & portal dockerfile, with some string replacement which looks like easy to break. And modifier of authgear Dockerfile & portal Dockerfile might not know this command is related to the once Dockerfile.
Another suggestion:
Use ENV AUTHGEARONCE=1
on top of the once Dockerfile, so that the builds automatically have AUTHGEARONCE=1
set and we don't have to do string replacements.
Normal Dockerfile
ENV AUTHGEARONCE=0 # Or can be omitted
...
RUN make build ...
Once Dockerfile
ENV AUTHGEARONCE=1
...
RUN make build ...
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.
Added two commits to address this.
I review the official doc on Dockerfile again, and it is better to use ARG
with default value.
We do not want to print out the sensitive environment variables accidentally.
Changing the user with `docker run --user` is not supported. So let's hard-code the username to make things more predictable.
So that people who see this in the home directory knows it is not the actual config file being used.
The client created in portal has this enabled by default already.
1. If ARG GIT_HASH is unused, remove it from the stage. 2. Remove explicit GIT_HASH assignment in the commandline. 3. Declare ARG AUTHGEARLITE and ARG AUTHGEARONCE before invoking make.
68ce325
to
51ec0af
Compare
No description provided.