-
-
Notifications
You must be signed in to change notification settings - Fork 20
Add dockerfile for automated mentoring support #12
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
Conversation
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.
node version
LTS please 💯
go version had certificates, user and stuff. are they needed for something?
@tehsphinx might have more on that, but in general it is probably a good thing to add a special user (such as deploy or analyzer-user) that will have execution rights to node and whatsnot. The certificates I think is to make sure the certificates are in sync given:
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwdshould I apk update?
Let's ask @ErikSchierboom and @tehsphinx
the two phase build should help keeping the final image small, so I wanted to copy only bin and dist. I had to copy node_modules too since the shell script needs the module esm. This could be fixed by copying only that module, or by creating an ad hoc package.json just to setup the final image (or we can just keep the build image as final image)
You may vendor package esm. Preferably by:
- add it to
devDependenciesand NOTdependencies - copy it from
node_modulesduring build / package
I changed
/bin/bashto/bin/shin theanalyze.shfile since bash is not present in linux-alpine
Fine with me!
What exactly is the question? (sorry for not understanding) |
I think it is whether one should do an Personally I do not hink its necessary. We can and should assume that The index, which was the main reason for doing Doing |
|
@NobbZ thank you for your elaborate answer and yes @ErikSchierboom what he said was the question! |
Dockerfile
Outdated
|
|
||
| # Create appuser | ||
| #RUN adduser -D -g '' appuser && mkdir /go-analyzer | ||
| RUN mkdir /javascript-analyzer |
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 the WORKDIR command is used later, the RUN mkdir can be removed - WORKDIR creates the directory if it does not exist
| @@ -1,4 +1,4 @@ | |||
| #!/bin/bash | |||
| #!/bin/sh | |||
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.
To make the script more cross-platform, perhaps the #!/usr/bin/env sh could be used here?
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.
Will that not conflict when using multiple arguments (https://stackoverflow.com/a/16365367)?
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.
Checked on my machine, no problems with passing several arguments to the script - $1 and $2 work as intended
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.
Plus I am using the #!/usr/bin/env sh in my Docker image, and it works there as well
| @@ -0,0 +1,3 @@ | |||
| test | |||
| dist | |||
| node_modules | |||
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 the git commands are not used in the Dockerfile, it would make sense to add the .git directory here.
This way the Docker cache will not be invalidated when the git commands are run on the developer machine
Dockerfile
Outdated
| COPY --from=builder /javascript-analyzer/bin /opt/analyzer/bin | ||
| COPY --from=builder /javascript-analyzer/dist /opt/analyzer/dist | ||
| COPY --from=builder /javascript-analyzer/node_modules /opt/analyzer/node_modules | ||
| RUN chmod +x /opt/analyzer/bin/analyze.sh |
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.
If storing executable scripts is OK for you, the chmod could be run on the repository file.
Docker saves the file permissions when they are copied.
Then this line can be removed.
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.
Dockerfile
Outdated
| WORKDIR /javascript-analyzer | ||
|
|
||
| # get the rest of the source code | ||
| COPY . /javascript-analyzer |
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.
This can be simplified to the COPY . .. You are already in the javascript-analyzer directory, because of the previous WORKDIR command.
|
About the certificates and the user: |
|
About
Again: security. If we leave it out the builds are dependent on the underlying container to bring in security updates regularly. |
|
I personally prefer to do the |
|
Regarding the |
@depsir per this, can we also add the certificates :) ? |
SleeplessByte
left a comment
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've added suggestion inline which I'll apply -- let's see if this flies. Amazing work @depsir 🚀 🚀 🚀
* Create CODE_OF_CONDUCT (originally @SleeplessByte exercism/javascript-analyzer#5) * Add dockerfile for automated mentoring support (originally @depsir exercism/javascript-analyzer#12) * Initial smoke for usage of jest (originally: @SleeplessByte exercism/javascript-analyzer#17) * Apply design and proper interface and structure (originally: @SleeplessByte exercism/javascript-analyzer#18) * Fixes issues in the README.md (originally: @zeckdude exercism/javascript-analyzer#19)
* Create CODE_OF_CONDUCT (originally @SleeplessByte exercism/javascript-analyzer#5) * Add dockerfile for automated mentoring support (originally @depsir exercism/javascript-analyzer#12) * Initial smoke for usage of jest (originally: @SleeplessByte exercism/javascript-analyzer#17) * Apply design and proper interface and structure (originally: @SleeplessByte exercism/javascript-analyzer#18) * Fixes issues in the README.md (originally: @zeckdude exercism/javascript-analyzer#19)
I created a first draft of dockerfile, inspired by the go-analyzer, having in mind the guidelines of automated-mentoring-support.
This pr is intended to fix #7
Some info about the choices made:
node_modulesafteryarn install --prod, to keep only runtime needed dependencies/bin/bashto/bin/shin theanalyze.shfile since bash is not present in linux-alpine, probably it could be#!/usr/bin/env sh