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 images #59

Merged
merged 14 commits into from
Oct 22, 2017
Merged

🐳 Docker images #59

merged 14 commits into from
Oct 22, 2017

Conversation

danirod
Copy link
Member

@danirod danirod commented Aug 12, 2017

This PR is used to create and test Docker images. The PR will be merged once there is a stable Docker image that works on development and testing environments. It might be possible to modify the built Docker image so that it can be used in production environments but it will be outside of the scope of this PR because I don't know what can I expect from it.

Tasks

  • Add a Dockerfile for building the web application.
  • Add a docker-compose for development (makigas app + PostgreSQL + ...).
  • Allow running tests with RSpec using Docker and maybe a separate docker-compose.

Other things to look

  • Can Alpine Linux be used as the base image for the Dockerfile? The Dockerfile currently uses Ubuntu for the base image. Alpine can produce smaller images. There is a Ruby image based on Alpine Linux but I have to figure out how to install the dependencies and Node.js on Alpine since currently the web application has been verified to work in DPKG distributions (Debian, Ubuntu).
  • Can this be used for running the Docker container in a staging or production server or should the Dockerfile be restricted to development and testing environments for the sake of how easy to set up it is?

Tracking Issue

Assigned tracking issue for this feature is #52.

The default database.yml supports multiple environments because often
there are multiple databases involved in a web application instance,
specially on local development machines, where you often have the
_development and the _test database.

However, when the application runs through Docker, an alternative
approach is used and instead of multiple instances, there is a single
database instance.
This commit will add a docker-compose.yml file that can be used to run
the application in a development environment. Note that the application
has not been tested to be suitable for testing environments yet. The
docker-compose is not valid for production environments because it
mounts the entire code as a volume.
@danirod danirod self-assigned this Aug 12, 2017
Docker doesn't seem to properly clean-up the Rails application when it
stops, so the remaining server.pid confuses Rails the very next time it
starts up.
This reduces the overall image size.
After removing node_modules/ in my host directory, I noticed that the
application stopped working inside the container.

Apparently, because I'm mounting . into the container, it doesn't matter
the Dockerfile runs yarn install: the node_modules directory in the
container gets hidden when the whole application directory is replaced
by the root contents. That means that it's still required to run yarn
install on the host to make node_modules be available in the container.

To avoid this, the volume-in-volume Docker trick is added in this
commit, by using information described in this article here [1].
Container's node_modules directory is remounted after binding the
application directory. This makes the original /makigas/node_modules
directory available, even if the host system doesn't have this
directory.

This trick is also used as a workaround to replace tmpfs introduced in
commit de9c93f with a local and persistent mounting point that survive
stopping and restarting the container.

[1]: http://jdlm.info/articles/2016/03/06/lessons-building-node-app-docker.html#the-node_modules-volume-trick
MAINTAINER is deprecated. Replace with LABEL.

Plus, CMD is back to the Dockerfile. To avoid the testing setup to run a
Rails server, it overrides the command so that instead of spawning a
server it just runs /bin/true. It works the same.
@danirod danirod merged commit 04ee059 into master Oct 22, 2017
@danirod danirod deleted the docker branch October 22, 2017 15:24
@danirod danirod mentioned this pull request Oct 22, 2017
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.

1 participant