From a15a7d8a95dd36f022d2fca5c22e5257414e85e9 Mon Sep 17 00:00:00 2001 From: Matteo Giaccone Date: Thu, 6 Dec 2018 20:20:01 +0100 Subject: [PATCH] Fix Docker setup This commit fixes the Docker setup and also the CI build. Also the contributing guide is updated with the new information related to Docker. The CONTRIBUTING.md file is used to comply with GitHub guidelines to help other developers to contribute. --- CONTRIBUTING.md | 29 +++++++++++++++++++++++++++++ Dockerfile | 2 ++ Dockerfile.passenger | 41 ----------------------------------------- doc/README_DEVELOPERS | 43 ------------------------------------------- docker-compose.yml | 11 ++++++----- script/cibuild | 1 + 6 files changed, 38 insertions(+), 89 deletions(-) create mode 100644 CONTRIBUTING.md delete mode 100644 Dockerfile.passenger delete mode 100644 doc/README_DEVELOPERS diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..759c7b01 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing +All contributions are welcome. + +There are different ways in which you can contribute to Tracks. + +## Documentation +You can contribute documentation in the [wiki](https://github.com/TracksApp/tracks/wiki). + +For example: +- tutorials on installing Tracks in various environments +- tutorials on using Tracks (user manual) + +## Issues +If you think having found a problem with Tracks, first search in the [existing issues]((https://github.com/TracksApp/tracks/issues). If you cannot find it, open a new issue and try providing information on your setup and what steps are needed to reproduce the problem. + +## Enhancements +It would be great to first discuss them on the [mailing list](https://groups.google.com/group/TracksApp) so you can figure out if it could be merged or not. You may use the wiki too to describe your change if it is too big for an email. + +If you want to contribute an enhancement or a fix, you can: + +1. [fork the project](https://help.github.com/articles/fork-a-repo) +1. [create a topic branch](http://learn.github.com/p/branching.html). +1. setup the project with [docker-compose](https://docs.docker.com/compose/) by running `docker-compose up` +1. then run `./bin/setup` to setup the first run +1. if you need, you can launch a Rails console with `./bin/rails c` (will run inside Docker) +1. make your changes and adds/updates relevant tests. +1. run the test suite with `./bin/rake test` (will run inside Docker) +1. commit the changes +1. send a pull request. diff --git a/Dockerfile b/Dockerfile index e262e54b..bef29c2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,6 @@ RUN mkdir /app/log COPY . /app/ +RUN cp /app/config/site.yml.tmpl /app/config/site.yml + EXPOSE 3000 diff --git a/Dockerfile.passenger b/Dockerfile.passenger deleted file mode 100644 index 777369fc..00000000 --- a/Dockerfile.passenger +++ /dev/null @@ -1,41 +0,0 @@ -FROM phusion/passenger-ruby22:0.9.18 - -WORKDIR /home/app/tracks - -# Install gems -COPY Gemfile Gemfile.lock ./ -RUN bundle install --without development test mysql therubyracer --jobs=3 - -# Install and configure the app -ENV RAILS_ENV=production -ENV DATABASE_URL=sqlite3:/var/tracks/database.sqlite3 -RUN mkdir /var/tracks && chmod 777 /var/tracks -RUN touch /var/tracks/database.sqlite3 && chown app.app /var/tracks/database.sqlite3 -COPY . ./ -COPY config/site.yml.tmpl /etc/tracks/config/site.yml -RUN ln -sf /etc/tracks/config/site.yml config/site.yml -RUN bundle exec rake assets:precompile -RUN chown -R app.app . - -# Configure nginx -RUN echo "env DATABASE_URL;" > /etc/nginx/main.d/env.conf -RUN echo "\ -server {\n\ - listen 80 default_server;\n\ - server_name _;\n\ - root /home/app/tracks/public;\n\ - passenger_enabled on;\n\ - passenger_user app;\n\ - passenger_ruby /usr/bin/ruby2.2;\n\ -}" > /etc/nginx/sites-enabled/tracks.conf -RUN rm /etc/nginx/sites-enabled/default -RUN rm -f /etc/service/nginx/down - -# Migrate the database on startup -RUN echo "#!/bin/sh\nbundle exec rake db:migrate" > /etc/my_init.d/90_tracks.sh -RUN chmod +x /etc/my_init.d/90_tracks.sh - -VOLUME ["/etc/tracks", "/var/tracks"] - -# Default command for baseimage-docker -CMD ["/sbin/my_init"] diff --git a/doc/README_DEVELOPERS b/doc/README_DEVELOPERS deleted file mode 100644 index 49eaecbb..00000000 --- a/doc/README_DEVELOPERS +++ /dev/null @@ -1,43 +0,0 @@ -1. Resources - -Tracks is using -* GitHub to host the git repository, manage git pull requests, and manage bugs and enhancement requests. -* the mailing list to discuss features and development and interact with users - -See README for links to the respective sites - -Also see the Development pages on the wiki for details on installing, testing, -upgrading, etc. - -2. Dependencies - -The dependencies for Tracks are maintained using bundler. Before starting your -tracks instance, you'll need to run 'bundle install' to fetch all the -dependencies - -3. Testing - -There are some pointers for setting up your Tracks copy for testing at -https://github.com/TracksApp/tracks/wiki/Testing/ - -By default, tests are configured to run using sqlite3 in memory mode to -increase speed. You will need the sqlite3-ruby gem for this. - -To avoid showing the migrations as tests are run, add the following to your -database.yml below 'database: ":memory:"': - - verbosity: quiet - -If you want to run tests using another database, that's fine, too. Just change -your database.yml accordingly. - -Running cucumber/selenium tests in :memory mode does not seem to work. - -The rspec tests are not actively maintained. - -See the wiki for more information on testing: -https://github.com/TracksApp/tracks/wiki/Testing - -4. Contributing - -See https://github.com/TracksApp/tracks/wiki/How-to-contribute \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 82fbb252..093c35ff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,17 +3,18 @@ services: db: image: mysql:5.7 environment: - MYSQL_ALLOW_EMPTY_PASSWORD: '1' + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + MYSQL_DATABASE: ${TRACKS_DB:-tracks} volumes: - - "db-data:/var/lib/mysql" + - db-data:/var/lib/mysql web: build: . + command: rails s volumes: - - "${VOLUME:-.:/app/workdir}" + - ${VOLUME:-.:/app} ports: - - "3000:3000" + - 3000:3000 depends_on: - db volumes: db-data: - diff --git a/script/cibuild b/script/cibuild index d6de0df1..702cf364 100755 --- a/script/cibuild +++ b/script/cibuild @@ -16,6 +16,7 @@ function die() { trap cleanup EXIT export RAILS_ENV=test +export TRACKS_DB=tracks_test # Put a config/site.yml file in place since it's needed for operation cp config/site.yml.tmpl config/site.yml