nicbet / docker-phoenix

A dockerized Phoenix development and runtime environment.
GNU General Public License v3.0
277 stars 57 forks source link

Add Version Number for Node JS, as well as ENV Param for Phoenix #22

Closed restlessronin closed 2 years ago

restlessronin commented 2 years ago

I needed to be able to build a more recent NodeJS version into the container, so I parameterized both the phoenix version as well as the NodeJS version.

My primary machine is a Mac M1 which has problems with amd64 images. I added a couple of build scripts to simplify multi-arch builds (via manifest pushing, since I couldn't get buildx working as advertised). My process was:

run on amd64 machine:

./buildarch.sh amd64 1.6.2

then run on an m1

./buildarch.sh arm64 1.6.2
./buildmulti.sh 1.6.2
nicbet commented 2 years ago

Hi @restlessronin, thanks for the PR.

I like the parametrization of the Node and Phoenix versions! Wondering whether standardizing on a Makefile would make sense to keep the number of sh scripts down?

Also looking at the changes in the PR, you have a number of references to your own Docker hub URLs and accounts in there. I've opened #23 to track moving the image away from Docker Hub to Github ghcr.io in the next little while.

restlessronin commented 2 years ago

Yeah. It might make sense to organize the build scripts, but I don't have an informed opinion on the best way to do that.

It might also make sense to separate the docker image build project and the sample phoenix project that utilizes the dockerfile. 1) The sample phoenix project should have the .devcontainer in it, but no build scripts or phoenix dockerfile. 2) The docker image project would have the main phoenix dockefile, build scripts, build environment etc, but either no .devcontainer or a different one that can actually be used to build the docker image.

Yes, I had to use my own docker repo in order to build the m1 docker image for testing. Would shifting to ghcr.io solve that problem?

nicbet commented 2 years ago

Yes true, we can organize the code better by splitting the docker image building and the VSCode integration via .devcontainer into separate directories. I've opened #24 to look at that.

In the meantime:

  1. could you change the values hardcoded restlessronin to nicbet
  2. could you change the ENV calls in the Dockerfile to ARG, since these are build-time settings that we may want to override at build time (see below)
  3. could you change the hardcoded value for NODEJS_VERSION back to 12.x for now, you can override it in your own build (see below)

For your customized build you can then override the default by passing --build-arg VAR=VALUE to the docker build command, e.g.:

docker build -t restlessronin/docker-phoenix:latest --build-arg NODEJS_VERSION=17.x
restlessronin commented 2 years ago

Made all the changes.

Thanks for the tip on creating my custom build.

nicbet commented 2 years ago

@restlessronin Thanks again for your contribution! I've integrated them into the latest master branch by hand, as there were a few issues around building the multiarch images with GitHub Actions.

Closing this PR.

restlessronin commented 2 years ago

Thanks @nicbet . Sorry, I'm a DevOps noob, so still haven't got the hang of things. I'll try to provide more immediately usable PRs in the future.

nicbet commented 2 years ago

@restlessronin no worries - the content in the PR was very useful. Just setting up GH actions and getting things right required changes from my end as repo owner that you couldn't have added through a PR. Thanks again!