firstdraft / appdev_template

A Rails template for generating homework projects
0 stars 1 forks source link

Update Dockerfile to improve build time and size #170

Closed jelaniwoods closed 3 years ago

jelaniwoods commented 3 years ago

The current base image, gitpod/workspace-full:latest, that we've been using is very large— around 7.19GB before any appdev stuff is installed. Afterwards the images end up being 8-9GB!

This limits the number of images you can store on your computer, increases build time, and increases the time it takes to push to Docker Hub.

The proposed changes start from an ubuntu base image that starts at 72.9MB. Once all the necessary programs are installed, the image size is around 2.21GB (2.73GB with R, Python3, wkhtmltopdf, graphviz, and imagemagick installed)— which is much more manageable!

Starting from ubuntu, we need to install

We also need to make a non-root user (gitpod) and configure it to work with sudo

https://github.com/firstdraft/appdev_template/blob/9922296e84cfe4b1c63244a92ce1e205c6d41b11/files/Dockerfile#L24-L28

Everything else is the same or were hacks to get around configuration in the gitpod/workspace-full image that are no longer necessary.

The only layers that need to re-build between projects are

https://github.com/firstdraft/appdev_template/blob/6bb2fa0bb4ab7e2c22fefe260b7a8d14eb085721/files/Dockerfile#L58-L64

so the bottleneck is basically sassc and to a lesser degree nokogiri.

bundler is always installed so we don't have to worry about having the wrong version of bundler installed.

Heroku CLI is always installed so it's up to date and students don't see warning messages about it being out of date.

This was tested with this repo: https://github.com/appdev-projects/photogram-final/tree/jw-fall20-updates

raghubetina commented 3 years ago

Great thinking! Are there any other libraries that would be handy to have pre-installed in addition to Chromedriver? I can think of Imagemagick (used by lots of image processing libraries), Graphviz (used by rails-erd). Any others?

raghubetina commented 3 years ago

Perhaps having Python and/or R installed might be useful for demonstrating how to shell out to other programs?

raghubetina commented 3 years ago

Are there any libraries that would be helpful to pre-install for VSCode extensions? Beautifiers? Intellisense?

raghubetina commented 3 years ago

Perhaps wkhtmltopdf (used by wicked_pdf)?

I've fielded a handful of final projects that need to generate e.g. PDF invoices and usually recommend Prawn since it's pure Ruby with no dependencies, but I've been preferring wicked_pdf over Prawn lately since the former lets you write HTML and CSS rather than learn a DSL.

jelaniwoods commented 3 years ago

@raghubetina I've made updates to include:

Could you take another look?

raghubetina commented 3 years ago

This looks great and I would be happy merging. Curious though about whether installing Solargraph or something similar would prevent those constant error pop-ups that we see?

And my other q re: formatters for e.g. rb and erb files?

jelaniwoods commented 3 years ago

Curious though about whether installing Solargraph or something similar would prevent those constant error pop-ups that we see?

@raghubetina Which error messages do you mean? I haven't seen any popups in a few quarters. Gitpod shouldn't have Solargraph installed by default anymore and the settings were reverted in this PR https://github.com/firstdraft/appdev_template/issues/153

The htmlbeautifier extension has been added to all projects this quarter, done in https://github.com/firstdraft/appdev_template/pull/152 .

I've only ever used Rubocop before, is there a Ruby formatter that you prefer that follows the same convention of Format Document in the command palette?

raghubetina commented 3 years ago

@jelaniwoods I like Rufo — it's a bit more unobtrusive than RuboCop. Can we hook this up to "Format Document"?

Gitpod shouldn't have Solargraph installed by default anymore and the settings were reverted in this PR #153

Gotcha, maybe I was just seeing them on old repos that I had previously forked. I'm still curious about the benefits of Solargraph/Intellisense but until we observe benefits in our own coding workflows I think we can leave it out for students.

The htmlbeautifier extension has been added to all projects this quarter, done in #152 .

Great.

jelaniwoods commented 3 years ago

@raghubetina rufo is now installed and with this extension it hooks into Format Document and works as expected.

jelaniwoods commented 3 years ago

Perhaps it worth watching this to see what extensions and settings to use.

raghubetina commented 3 years ago

Good idea; especially now that full VSCode is coming to Gitpod.