-
Notifications
You must be signed in to change notification settings - Fork 31
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
Created Dockerfile and updated ReadMe #121
Conversation
@@ -9,7 +9,7 @@ | |||
], | |||
"scripts": { | |||
"develop": "gatsby develop", | |||
"start": "gatsby develop", | |||
"start": "gatsby develop --host=0.0.0.0", |
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.
How does this æffect running it in production? (if at all) @niklasmtj
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 shouldn't effect it at all since we're pushing the public folder to GH pages
Dockerfile
Outdated
|
||
# Expose port for server | ||
EXPOSE 8000 | ||
|
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.
Talked to @samueltauil about this. I would rather not run it as root if at all possible.
I would suggest adding something like
RUN chown -R 1001:0 /gitops-website && chmod -R ug+rwx /gitops-website
USER 1001
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.
Maybe we can even use node:16-alpine
? This way we could use the node
user
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.
In general I like this. But I have a few questions concerns before I can approve.
- Does this emulate the env that the site is running on? (I'm mainly concerned about the version of node)
- The Container would run as root. Which isn't terrible if you're just developing locally but we should probably do the best practice here.
- Looks like we need to change the
package.json
file. What is the implications? - DCO isn't passing.
I would suggest changing the name of the file from Dockerfile to Containerfile as the file where you define the instructions for building an OCI-compliant container image is traditionally named Dockerfile due to its widespread use and association with Docker, however, to avoid confusion or to align with a different ecosystem, some tools or environments might opt to use a different naming convention like Containerfile, especially if they're aiming to support multiple container runtimes or be more agnostic towards the containerization framework. I would also think of the Containerfile definition as this:
|
Okay I will refer to @christianh814 questions, and take suggestions from @samueltauil in order to prepare updated version. I was using alpine image as a base which can be problematic when there is a need to specify node version. |
Hi, I've updated PR with latest commit 🙂 Now as I commented earlier will refer to questions from @christianh814,
Refering to comment from @samueltauil, I've changed name as required 🙂 and used node image as base, but I was taught to use as lightweight image as possible so I'm always trying to use image that bases on minimal image possible. What Regards, P.S: using |
Hey @Veinar, thanks a lot for that PR! I'll have a look later today. |
Hi @niklasmtj, thanks for response 🙏 I'm not a professional tester, but I have successfully built containers using as a base image:
And I was able to display website using port mapping ( Please let me know, P.S: Possible versions of base image could be withdrawn using this command (bash): wget -q -O - "https://hub.docker.com/v2/namespaces/library/repositories/node/tags?page_size=1000" | jq -r '.results[] | select(.name | endswith("-alpine")) | .name' | sort -r P.S2: To use by default latest version of |
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.
Hey Konrad (@Veinar),
This looks like a great addition. Thanks again for this!
I got a few comments and suggestions on your changes after testing it locally. Still, I'm pretty happy with these changes!
Containerfile
Outdated
@@ -0,0 +1,32 @@ | |||
# Use the NODE_VERSION argument to specify the Node.js version | |||
ARG NODE_VERSION |
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.
ARG NODE_VERSION | |
ARG NODE_VERSION=20 |
I would suggest setting a default value here so we can also build it without the build argument if we want. What do you think?
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.
Ah before i forget. I used node-20 since this is the latest LTS version
README.md
Outdated
docker build --build-arg NODE_VERSION=19 --no-cache -t website:<tag> -f Containerfile . | ||
|
||
# Run container image with mapping port 80 on your computer | ||
docker run -dit -p 80:8000 website:<tag> |
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.
docker run -dit -p 80:8000 website:<tag> | |
docker run -dit -p 8000:8000 website:<tag> |
I understand why you default to 80 here and it also makes a lot of sense. What I think is that this might confuse folks since the console output for example says the following:
You can now view open-git-ops in the browser.
⠀
Local: http://localhost:8000/
Signed-off-by: Veinar <[email protected]>
Signed-off-by: Veinar <[email protected]>
Signed-off-by: Veinar <[email protected]>
Hi @niklasmtj, I made the changes based on your suggestions, thank you for picking out the node version that should be the default base for the application. In addition, I included in the comment when adding the As I wrote in the comment for Regards, |
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.
LGTM. Let's see what the other maintainers say
Thank you very much Konrad!
Hi team, any update on this ? @christianh814 or @samueltauil. Regards, |
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.
LGTM!
LGTM! with a note that I still support the usage of |
Thank you guys! 🙏 Konrad |
@Veinar thank you very much for your quick help! Really appreciate it |
Hi,
Briefly, I think i could resolve #120.
I've created basic
Dockerfile
that usesalpine
image as base - just to keep it as lightweight as possible.Then I added an environment variable without which the build would not pass
NODE_OPTIONS=--openssl-legacy-provider
.In the next step, I install the necessary dependencies using the
apk
command, in addition, I made sure to have a git on board in case I need to download something auxiliary.Before copying application files I create workdir (
gitops-website
) to store it in fixed place.After that Docker will copy all files from local filesystem. I didn't create a
.dockerignore
file because I'm not an expert on node applications and I don't know what might not be added to the final image. (I assumed everything was needed).Lastly I expose port
8000
on which node by default exposes running application, and created entry point accordingly to ReadMe file.I've had some issues with exposing application, and then I discovered that command:
gatsby develop
needs additional parameter (--host=0.0.0.0
) in order to listen on all interfaces which was required to reach application from outside of docker container. So I've made changes inpackage.json
and added this parameter into line withgatsby develop
as you can see in commit. Now it is only required to pass0.0.0.0
during port mapping indocker run
.Of course, I added information in the ReadMe file on how to build the image and how to run it.
Hope I helped,
Waiting for your review,
Regards,
Konrad 🙂