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

Improving docker #429

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ install:
- cp config/database.yml.example config/database.yml
- cp config/config.yml.example config/config.yml
- cp db/schema.rb.example db/schema.rb
- docker-compose build
- docker-compose run web bash -l -c "sleep 10"
- docker-compose run web bash -l -c "rake db:setup"
- docker-compose run web bash -l -c "rake db:migrate"
- docker-compose run web bower install --allow-root
- docker-compose up -d --build
- docker-compose exec web bash -l -c "sleep 10"
- docker-compose exec web bash -l -c "bundle install"
- docker-compose exec web bash -l -c "rake db:setup || rake db:migrate"

script:
- docker-compose run web bash -l -c "rake test"
- docker-compose exec web rake test
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Dockerfile # Mapknitter
# https://github.com/publiclab/mapknitter/
# This image deploys Mapknitter!

FROM debian:buster
LABEL This image deploys Mapknitter!

# Set correct environment variables.
RUN mkdir -p /app
ENV HOME /root

# Install dependencies
Expand Down Expand Up @@ -40,5 +40,8 @@ RUN sed -i "s/ LONG_PASSWORD |//g" /usr/local/rvm/gems/ruby-*/gems/mysql2-*/lib/

# Add the Rails app
WORKDIR /app
ADD . /app
RUN bower install --allow-root
COPY Gemfile /app/Gemfile
COPY Gemfile.lock /app/Gemfile.lock
COPY start.sh /app/start.sh

CMD [ "bash", "-l", "start.sh" ]
2 changes: 0 additions & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
//= require leaflet-providers/leaflet-providers.js
//= require leaflet-toolbar/dist/leaflet.toolbar.js
//= require leaflet-distortableimage/dist/leaflet.distortableimage.js
//= require leaflet-easybutton/src/easy-button.js
//= require leaflet-google/index.js
//= require sparklines/source/sparkline.js
//= require annotations-legacy.js
//= require glfx-js/dist/glfx.js
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//= require knitter
//= require exif-js/exif.js
//= require mapknitter
//= require seiyria-bootstrap-slider/dist/bootstrap-slider.min.js

/* Move navbar links into dropdown if nav is inside the sidebar. */
jQuery(document).ready(function($) {
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/maps.css.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*= require seiyria-bootstrap-slider/dist/css/bootstrap-slider.min.css
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, i think we might need this for the export resolution setting, can we test this out on a container before merging?

image

*= require jquery-ui/themes/overcast/jquery-ui.min.css
*/
/* Variables */
Expand Down
10 changes: 7 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'uglifier'

Mapknitter::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

Expand All @@ -9,13 +11,15 @@
config.action_controller.perform_caching = true

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
config.serve_static_assets = true

# Compress JavaScripts and CSS
config.assets.compress = true

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
config.assets.compile = true

config.assets.js_compressor = Uglifier.new(:harmony => true)

# Generate digests for assets URLs
config.assets.digest = true
Expand All @@ -38,7 +42,7 @@
# config.force_ssl = true

# See everything in the log (default is :info)
# config.log_level = :debug
config.log_level = :debug

# Prepend all log lines with the following tags
# config.log_tags = [ :subdomain, :uuid ]
Expand Down
46 changes: 26 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
db:
image: mysql:5.7
environment:
- MYSQL_DATABASE=mapknitter
- MYSQL_USER=mapknitter
- MYSQL_PASSWORD=mapknitter
- MYSQL_RANDOM_ROOT_PASSWORD=true
volumes:
- ../mysql:/var/lib/mysql
web:
build: .
command: ./start.sh
environment:
- RAILS_ENV=production
volumes:
- ./:/app
ports:
- "127.0.0.1:3000:3000"
links:
- db
version: '3.3'
services:
db:
container_name: db
image: mysql:5.6
env_file:
- mapknitter.env
volumes:
- /srv/mapknitter_priv1/mk1_database:/var/lib/mysql
web:
container_name: web
build: .
env_file:
- mapknitter.env
volumes:
- .:/app
- bundle_cache:/usr/local/bundle
- bower_cache:/app/public/lib
ports:
- 3000:3000
depends_on:
- db

volumes:
bundle_cache:
bower_cache:
5 changes: 5 additions & 0 deletions mapknitter.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MYSQL_DATABASE=mapknitter
MYSQL_USER=mapknitter
MYSQL_PASSWORD=mapknitter
MYSQL_RANDOM_ROOT_PASSWORD=true
RAILS_ENV=production