Skip to content
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

Docker setup with nginx #588

Merged
merged 5 commits into from
Jan 13, 2020
Merged

Docker setup with nginx #588

merged 5 commits into from
Jan 13, 2020

Conversation

skullydazed
Copy link
Member

So that we can share build artifacts between different projects (and because it's becoming more popular to develop locally using docker) I setup a docker container for configurator. We will be able to leverage this for both https://github.com/qmk/qmk_web_stack and https://github.com/qmk/qmk_configurator_appliance.

@noroadsleft noroadsleft requested a review from yanfali November 17, 2019 23:46
docker_build.sh Outdated Show resolved Hide resolved
Copy link
Collaborator

@yanfali yanfali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not terribly thrilled about including an entire copy of nvm.sh in the project, but I guess it'll have to do until someone has time to figure out a different way.

docker_build.sh Outdated

# Get yarn installed correctly
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
apt-get update
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has to be in the dockerfile

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because those calls can be cached into a docker layer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that it's still cached into a docker layer, and that it's a good idea to collapse your Dockerfile into as few layers as needed. Is my understanding wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but the whole layer will have the apt-get update and all the install of yarn and the project itself

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and that was my intent in arranging it this way. It bundles all the app dependencies together and ensures that stale dependencies don't break the app.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking to yan a bit yesterday we're revising the direction and goal of this PR. I'm going to rework it so that API requests are always proxied through nginx. This eliminates the need to yarn build at startup time, so I'll be refactoring this PR in a way that makes this conversation moot.

@skullydazed
Copy link
Member Author

Not terribly thrilled about including an entire copy of nvm.sh in the project, but I guess it'll have to do until someone has time to figure out a different way.

Yeah, all kinds of bad choices here, nothing good. I tried to curl | bash the install script, but it randomly fails. Same if I include the install script. This seemed like the least bad choice, because at least it works every time.

@zekth
Copy link
Contributor

zekth commented Nov 18, 2019

Not terribly thrilled about including an entire copy of nvm.sh in the project, but I guess it'll have to do until someone has time to figure out a different way.

why not just curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash ?

ref: https://github.com/nvm-sh/nvm/blob/master/README.md

docker_build.sh Outdated Show resolved Hide resolved
@zekth
Copy link
Contributor

zekth commented Nov 18, 2019

Could those scripts be in a script folder or a docker folder? having it in root can be a mess don't you think?

Not terribly thrilled about including an entire copy of nvm.sh in the project, but I guess it'll have to do until someone has time to figure out a different way.

Yeah, all kinds of bad choices here, nothing good. I tried to curl | bash the install script, but it randomly fails. Same if I include the install script. This seemed like the least bad choice, because at least it works every time.

Weird. Like network errors?

@skullydazed
Copy link
Member Author

Weird. Like network errors?

I'm not sure what was going on. I tried to debug it but the nvm code is pretty spaghetti-ish. Something that's part of generating the NVM URL ends up blanking it out, and I wasn't able to track down why or what. I can give it a try again after some of the reworking I talked to yan about.

@yanfali
Copy link
Collaborator

yanfali commented Nov 19, 2019

Weird. Like network errors?

I'm not sure what was going on. I tried to debug it but the nvm code is pretty spaghetti-ish. Something that's part of generating the NVM URL ends up blanking it out, and I wasn't able to track down why or what. I can give it a try again after some of the reworking I talked to yan about.

Looking forward to seeing the new version. My gut tells me that doing dependency resolution at runtime in docker is not the best way forward. Ideally at build time when we bake the container all dependencies are resolved and we just distribute the build artifacts. Hopefully that's also where Skully is aiming for. Other than that, very excited to see this project happen.

@skullydazed
Copy link
Member Author

This should ready to go. All API requests go through nginx now, and the only stuff in the build script is strictly related to providing a happy environment to nvm.

Dockerfile Show resolved Hide resolved
@yanfali
Copy link
Collaborator

yanfali commented Nov 22, 2019

@skullydazed can you give instructions on how to start the container? I tried docker run -it <image> and it didn't work. Also your recommended build command would also be good.

Changes look very good, but I wanted to test it locally before approval

@yanfali
Copy link
Collaborator

yanfali commented Nov 22, 2019

@skullydazed can you give instructions on how to start the container? I tried docker run -it <image> and it didn't work. Also your recommended build command would also be good.

Changes look very good, but I wanted to test it locally before approval

OK, I figured it out from the README. I think showing how to build it would be good to, but other than that I'm ready to approve this. Tested on macOS

@yanfali
Copy link
Collaborator

yanfali commented Nov 26, 2019

@skullydazed are you happy with this?

@skullydazed
Copy link
Member Author

I'm happy with the code itself. You wanted me to add build instructions to the readme and I haven't had a chance to sit down to do that yet.

@yanfali
Copy link
Collaborator

yanfali commented Dec 31, 2019

@skullydazed let me know when you're done with docs and we can merge this

@skullydazed
Copy link
Member Author

I've just added (and tested) instructions for building the container, and rebased from master. This PR should be ready to go.

@skullydazed
Copy link
Member Author

Build failure is due to force push causing a broken git command.

Copy link
Collaborator

@yanfali yanfali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only comment is the firs run takes a while as it downloads the source code, so might need a bit of text about that, but it can come as a separate update.

@yanfali yanfali merged commit c4d4a21 into master Jan 13, 2020
@yanfali yanfali deleted the docker_setup branch January 13, 2020 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants