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

Yarn transition work-in-progress #2659

Merged
merged 57 commits into from
Sep 10, 2018
Merged

Yarn transition work-in-progress #2659

merged 57 commits into from
Sep 10, 2018

Conversation

jywarren
Copy link
Member

@jywarren jywarren commented Apr 26, 2018

Solves #1215

@PublicLabBot
Copy link

PublicLabBot commented Apr 26, 2018

1 Message
📖 @jywarren Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.

Generated by 🚫 Danger

@jywarren
Copy link
Member Author

Running bower-away now

@jywarren
Copy link
Member Author

travis-ci/travis-ci#6720

@jywarren
Copy link
Member Author

Hmmm, Node version 0.10.29 is not supported, please use Node.js 4.0 or higher.

@jywarren
Copy link
Member Author

@ryzokuken any ideas?

@ryzokuken
Copy link
Member

@jywarren who throws this error? Yarn?

If we're on Node 0.x, we should definitely migrate. Node 4 has reached EOL, and ideally, we should jump to atleast Node 8.

@jywarren
Copy link
Member Author

jywarren commented Apr 28, 2018 via email

@ryzokuken
Copy link
Member

But travis allows you to use yarn. All you need to do is to check-in the yarn lockfile (which we should, and follow a policy similar to Gemfile.lock).

@jywarren
Copy link
Member Author

jywarren commented Apr 28, 2018 via email

@jywarren
Copy link
Member Author

Trying to do more research in https://blog.travis-ci.com/2016-11-21-travis-ci-now-supports-yarn and add a yarn.lock -- though don't know what that has to do with the node version... For now just trying to set node version more explicitly in .travis.yml -- and failing!

@jywarren
Copy link
Member Author

Hmm, looks like nvm is installing node 6 outside the container but not inside?

@jywarren
Copy link
Member Author

@jywarren
Copy link
Member Author

OK, locally i get:

[1/1] ⡀ phantomjs: Try to install PhantomJS globally
[-/1] ⡀ waiting...
[-/1] ⡀ waiting...
[-/1] ⡀ waiting...
error /home/warren/sites/plots2/node_modules/phantomjs: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: /home/warren/sites/plots2/node_modules/phantomjs
Output:
Considering PhantomJS found at /usr/bin/phantomjs
Found PhantomJS at /usr/bin/phantomjs ...verifying
PhantomJS detected, but wrong version 2.1.1 @ /usr/bin/phantomjs.

@jywarren
Copy link
Member Author

Getting closer -- i think we need help from @icarito maybe...

Step 9/23 : RUN rm /bin/sh && ln -s /bin/bash /bin/sh
 ---> Running in f85fe4dccf28
 ---> 6913a578b8d2
Removing intermediate container f85fe4dccf28
Step 10/23 : RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
 ---> Running in 4e881d19f410
 ---> b45713b2c669
Removing intermediate container 4e881d19f410
Step 11/23 : ENV NVM_DIR /usr/local/nvm # or ~/.nvm , depending
 ---> Running in c6392be267d2
 ---> 385ff8918de7
Removing intermediate container c6392be267d2
Step 12/23 : ENV NODE_VERSION 6
 ---> Running in edd3595d4c26
 ---> 98caca356cad
Removing intermediate container edd3595d4c26
Step 13/23 : RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.20.0/install.sh | bash     && . $NVM_DIR/nvm.sh     && nvm install $NODE_VERSION     && nvm alias default $NODE_VERSION     && nvm use default
 ---> Running in 333d9ab389ce
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5086  100  5086    0     0  45420      0 --:--:-- --:--:-- --:--:-- 45819
=> Downloading nvm from git to '/usr/local/nvm # or ~/.nvm , depending'
=> Cloning into '/usr/local/nvm # or ~/.nvm , depending'...
Note: checking out 'v0.20.0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
  git checkout -b new_branch_name
HEAD is now at 8964cb4... v0.20.0
=> Appending source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm
/bin/sh: /usr/local/nvm: No such file or directory
Service 'web' failed to build: The command '/bin/sh -c curl https://raw.githubusercontent.com/creationix/nvm/v0.20.0/install.sh | bash     && . $NVM_DIR/nvm.sh     && nvm install $NODE_VERSION     && nvm alias default $NODE_VERSION     && nvm use default' returned a non-zero code: 1

@icarito
Copy link
Member

icarito commented Apr 30, 2018

I would rather we used prepackaged node rather than nvm if possible there are debian packages we can use or ideally a ready made base image. https://hub.docker.com/ is really slow for me but I'd look for an image with the right Node version and then install the ruby packages from the distro.

@icarito
Copy link
Member

icarito commented Apr 30, 2018

maybe we can switch to one of these: https://hub.docker.com/_/node/

@jywarren
Copy link
Member Author

jywarren commented Apr 30, 2018

Hmm, interesting:

Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
section: 'hoe'

I don't see hoe in either Gemfile or Gemfile.lock...

@jywarren
Copy link
Member Author

@icarito
Copy link
Member

icarito commented May 1, 2018

Thanks for enduring build experiments with me.
So in Debian Stretch we have specific versions that aren't going to change. We could aim at locking into those - this could have the impact of reducing some of our update burden because we can generally depend on Debian to support packages etc and security. Or we can ride the wave and try to keep up with newest.
I found there's a Docker image called ruby-node that tries that last path so I was tempted to try it, but the "maintained version" whatever that means would bump Ruby to 2.5.

Thinking over this again I think the best approach is to return to Ruby base image as that is what ruby-node's Dockerfile does and install the desired Node version on top.

We really shouldn't think of nvm or rvm in containers as containers are disposable by nature and get rebuilt with the exact desired versions, generally no need for version managers except at build time.

@jywarren
Copy link
Member Author

jywarren commented May 1, 2018

That's fine, i'm not wedded to nvm its just what we often use in development. I'm also fine with not being the latest node version. Honestly i'd just be happy to see the build succeed :-P it was a bit harder than I thought, given that the only issue remaining seemed to be the node version!

@jywarren
Copy link
Member Author

@icarito -- any suggestions on this?

@icarito
Copy link
Member

icarito commented May 25, 2018

Sooner rather than later we will need to upgrade our container to Stretch.
In this process we can add the stretch-backports repo that serves v8.11.2 LTS.
That would be the simplest path forward. The manual way of installing it looks a bit convulted:
https://github.com/Starefossen/docker-ruby-node/blob/master/2-8/stretch/Dockerfile

@jywarren
Copy link
Member Author

Sooner rather than later we will need to upgrade our container to Stretch.

OK, so let's try first opening a new PR for the Stretch port, then return to this. @ryzokuken if you can try this out, just be sure to link back to here so there's a next step.

@ghost ghost assigned jywarren Jun 8, 2018
@jywarren
Copy link
Member Author

jywarren commented Jun 8, 2018

Seeing:

Node version 0.10.29 is not supported, please use Node.js 4.0 or higher.

@ryzokuken
Copy link
Member

@jywarren makes sense, it's bad if we're at Node v0.10.x, let's switch to Node v10.x instead.

@jywarren
Copy link
Member Author

jywarren commented Jun 10, 2018 via email

@Souravirus
Copy link
Member

Hi @jywarren, @icarito now all the tests are passing here as well as the deployment to unstable branch is working fine. Please review this.

@jywarren
Copy link
Member Author

jywarren commented Sep 7, 2018

This is great. 🎉 Can you give us a checklist on anything that has to be done on production for this to work? Or do you and @icarito anticipate that it'll run smoothly.

And one more thing - have you been able to double check that the most current bower.json file has been copied over (with accurate version numbers) to package.json?

@Souravirus
Copy link
Member

Yeah I will check the bower.json file again to see if any libraries are missing. Other than that I have made it to work smoothly in production but it would be great if @icarito can review this once.

@jywarren
Copy link
Member Author

jywarren commented Sep 7, 2018 via email

@Souravirus
Copy link
Member

All the packages are according to bower.json except the leaflet-environmental-layers as yarn doesn't have 1.0.1 version of it. So, we have to take the 1.0.0 version of it.

Copy link
Member

@icarito icarito left a comment

Choose a reason for hiding this comment

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

Other than the build order, this looks fine to me! Congratulations, this is a long effort!
Thanks again.

.travis.yml Outdated
#language: node_js
#node_js: '6'
#cache: yarn # This caches `$HOME/.yarn-cache`

Copy link
Member

Choose a reason for hiding this comment

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

Please remove these comments unless they help somehow!

Copy link
Member

Choose a reason for hiding this comment

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

Ok I wiil remove these

Makefile Outdated
docker-compose exec web rake assets:precompile
docker-compose exec web rake tmp:cache:clear
docker-compose down --remove-orphans
rm -f ./tmp/pids/server.pid
docker-compose up -d
docker-compose exec -T web yarn --ignore-engines --ignore-scripts --modules-folder public/lib
Copy link
Member

Choose a reason for hiding this comment

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

You've removed the javascript package installation from line 10/11 and put it into line 15. This effectively waits until after rebooting the Rails app to get going with Javascript installation. So if Javascript installation fails, you've already restarted the app possibly broken by missing Javascript dependencies. If you move this line to line 10, then if yarn fails the app is still running fine and no harm was done. If you agree please do so! Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Ok I will move the yarn installation command to line 11. Thanks

Makefile Outdated
docker-compose run web rake assets:precompile
rm -f ./tmp/pids/server.pid
docker-compose up -d
docker-compose exec -T web yarn --ignore-engines --ignore-scripts --modules-folder public/lib
Copy link
Member

Choose a reason for hiding this comment

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

Again here, you wait till after deploying the container to install Javascript packages, I think the same applies here. Thanks!

@icarito
Copy link
Member

icarito commented Sep 8, 2018

@jywarren This morning it came to me that you may find it won't deploy cleanly with redeploy-container method (because in the first part of the process it'll exec yarn but yarn isn't installed in the current image). I guess this is why @Souravirus put this command after restarting the container (because then yarn will be available).
In these cases (like when we upgrade ruby) - when redeploy-container fails, our Makefile has deploy-container task which we can use to deploy from a stopped container status.

@Souravirus
Copy link
Member

Yeah right @icarito putting yarn before restarting the container is giving error as you can see in https://jenkins.laboratoriopublico.org/job/Plots-Unstable/296/console . So, I guess best is to use the yarn command after starting the container. What do you think @icarito.

@icarito
Copy link
Member

icarito commented Sep 10, 2018

Thanks @Souravirus for giving it a try! I think this is pinpointing an issue we've been having with deployment to production being somewhat unstable when upgrading stuff like Ruby. We've been using docker-compose exec. I think we should be using docker-compose run --rm. I'll issue commit for this and try it!

@ghost ghost assigned icarito Sep 10, 2018
@icarito
Copy link
Member

icarito commented Sep 10, 2018

I think this is working fine in unstable now! @jywarren and the docker-compose bit should make it reliable to upgrade onwards.

@icarito icarito changed the title Yarn transition work-in-progress (help-wanted) Yarn transition work-in-progress Sep 10, 2018
@jywarren
Copy link
Member Author

OK, shall I merge this in then? SUPER!!!

@Souravirus
Copy link
Member

Yeah its ready @jywarren

@jywarren jywarren merged commit 5c2bce3 into master Sep 10, 2018
@ghost ghost removed the in progress label Sep 10, 2018
@jywarren
Copy link
Member Author

🎉 !!!

@jywarren
Copy link
Member Author

This is live!!!!!

@Souravirus Souravirus deleted the yarn branch September 11, 2018 22:02
@Souravirus
Copy link
Member

We have to change the documentation for the change from bower to yarn. I guess making a first-timer issue of it will work.

@Souravirus
Copy link
Member

I guess we can make it a code-in task too. What do you think @jywarren

@jywarren
Copy link
Member Author

jywarren commented Sep 11, 2018 via email

SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this pull request May 5, 2019
* Yarn transition work-in-progress (help-wanted)

* switch to yarn attempt

* changed root location of packages

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update Dockerfile

* Update .travis.yml

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Remove reference to unneeeded installations

Keep minimal.

* Still more tweaking for switching base OS image

* Add .dockerignore

Trying with ignored Gemfile.lock

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Added yarn.lock

* Added phantomjs-prebuilt to package.json and yarn.lock

* Removed separated installation of phantomjs-prebuilt

* Run forced installation of yarn

* Removed bower.json and .bowercc

* Added noty and jquery-confirm

* Modifications in Dockerfile

* Added yarn install in .travis.yml

* Added lel packages to package.json

* Added yarn command  in .gitlab.yml

* Deleted bower command from .gitlab-ci.yml

* Changes in .gitlab-ci.yml

* Updated yarn according to bower

* Deprecated lel version

* Changes in Makefile

* Removed bower from Makefile

* Added rack-test to Gemfile

* Modified Dockerfile according to current version

* Changes in Gemfile.lock related to ruby 2.4.4

* Makefile changes related to ruby 2.4.4

* Removed bundle install command in .travis.yml

* Added i18n Gem to Gemfile

* Changes in Dockerfile related to npm error Hostname/IP doesn't match certificate's altnames

* Changes in Dockerfile related to jobs option of bundle install

* Removed Gemfile.lock in .dockerignore

* Changes in .dockerignore

* Changes in .dockerignore

* Added Gemfile.lock in Dockerfile

* Updated Gemfile.lock

* Changes in .dockerignore

* Modified way of installing bundler

* Updated Dockerfile

* Some changes in Dockerfile

* Some changes

* Changes in package.json

* Removed comments in .travis.yml

* Redeploy independent container

* Use bash command line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants