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 #363

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a0aed1a
Shortening docker image in ~30%
alaxalves Feb 27, 2019
bad2af5
Caching bundle, gathering env variables and using newer sintax
alaxalves Feb 27, 2019
a43d22b
Creating startup script and env file
alaxalves Feb 27, 2019
c59753b
Improving travis CI configuration
alaxalves Feb 27, 2019
e7c5015
Loading assets in production env
alaxalves Mar 5, 2019
5a64224
Allow uglifier to interpret ES6
alaxalves Mar 5, 2019
a3bf9f6
Upgrade to mySQL5.7, Ruby warning reductions, .md file updates (#355)
sashadev-sky Mar 11, 2019
3b7ca30
Spam button with "ban" icon (#398)
govindjeevan Mar 12, 2019
c0a2c55
Fix navbar medium screen sizes collapse behavior + change color (#399)
Mar 13, 2019
37add66
Create first-timers-issue-template.md
jywarren Mar 13, 2019
29ab3d8
Create first-timers.yml
jywarren Mar 13, 2019
804f27e
Update first-timers-issue-template.md
jywarren Mar 13, 2019
209ea2f
Update first-timers-issue-template.md
jywarren Mar 13, 2019
2522084
Delete first-timers-issue-template.md
jywarren Mar 13, 2019
c2e5aba
Update first-timers-issue-template.md
jywarren Mar 13, 2019
71a284f
Update first-timers-issue-template.md
jywarren Mar 13, 2019
208bf80
Update first-timers.yml
jywarren Mar 13, 2019
24ac85c
Update utility_controller.rb
jywarren Mar 13, 2019
2d3c168
Add files via upload
jywarren Mar 13, 2019
ed7a96c
Update _sidebar_exports.html.erb
jywarren Mar 13, 2019
1ef7ab0
accept uploads from images only (#356)
Jordenng Mar 16, 2019
628b8b5
Modularization of export code (#341)
jywarren Mar 16, 2019
afa176c
Bump will_paginate from 3.1.6 to 3.1.7 (#414)
dependabot[bot] Mar 19, 2019
f3fa25b
fix outdated ruby versions listed in README #412 (#416)
coreytegeler Mar 19, 2019
7c00261
Update config.yml
jywarren Mar 19, 2019
f4650a7
Deployment tweaks including Makefile and start script (#418)
icarito Mar 20, 2019
b86f990
Merge commit 'refs/pull/363/head' of http://github.com/publiclab/mapk…
icarito Mar 21, 2019
c874b4c
Don't dettach when building container in travis
icarito Mar 21, 2019
144e3a3
Fix start command
icarito Mar 21, 2019
eb29376
Fix travis script
icarito Mar 21, 2019
7546deb
Try to resolve travis tests invocation
icarito Mar 21, 2019
e794d09
Tweak travis script
icarito Mar 21, 2019
ce41acd
Add delay
icarito Mar 21, 2019
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
10 changes: 9 additions & 1 deletion .github/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ firstPRMergeComment: |
Your code will likely be published to https://mapknitter.org in the next few days.
In the meantime, can you tell us your Twitter handle so we can thank you properly?
Now that you've completed this, you can help someone else take their first step!
See: [Public Lab's coding community!](https://code.publiclab.org)
Reach out to someone else working on theirs on [Public Lab's code welcome page](https://code.publiclab.org#r=all). Thanks!
<details>
<summary><b>Help others take their first step</b></summary>
<p>Now that you've merged your first pull request, you're the perfect person to help someone else out with this challenging first step. 🙌 </p>
<p><a href="https://code.publiclab.org#r=all">https://code.publiclab.org</a></p>
<p>Try looking at this list of `first-timers-only` issues, and see if someone else is waiting for feedback, or even stuck! 😕 </p>
<p>People often get stuck at the same steps, so you might be able to help someone get unstuck, or help lead them to some documentation that'd help. Reach out and be encouraging and friendly! 😄 🎉 </p>
<p>Read about <a href="https://github.com/publiclab/plots2/issues/3458">how to help support another newcomer here</a>, or find <a href="https://github.com/publiclab/plots2/labels/support">other ways to offer mutual support here</a>.</p>
</details>

# It is recommended to include as many gifs and emojis as possible
8 changes: 5 additions & 3 deletions .github/first-timers-issue-template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Hi, this is a [first-timers-only issue](https://code.publiclab.org#r=all). This means we've worked to make it more legible to folks who either **haven't contributed to our codebase before, or even folks who haven't contributed to open source before**.
Hi, this is a [first-timers-only issue](https://code.publiclab.org/#r=all). This means we've worked to make it more legible to folks who either **haven't contributed to our codebase before, or even folks who haven't contributed to open source before**.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝

If you have contributed before, **consider leaving this one for someone new**, and looking through our general [help wanted](https://github.com/publiclab/mapknitter/labels/help-wanted) issues. Thanks!
If you have contributed before, **consider leaving this one for someone new**, and looking through our general [help wanted](https://github.com/publiclab/plots2/labels/help-wanted) issues. Thanks!

### 🤔 What you will need to know.

Expand All @@ -16,6 +16,8 @@ Nothing. This issue is meant to welcome you to Open Source :) We are happy to wa

- [ ] 📝 **Update** the file [$FILENAME]($BRANCH_URL) in the `$REPO` repository (press the little pen Icon) and edit the line as shown below.

To get help installing the application on your computer, see [the project README](https://github.com/publiclab/mapknitter/tree/main/README.md) and get help at #307

[See this page](https://code.publiclab.org/#r=all) for some help in taking your first steps!

Below is a "diff" showing in red (and a `-`) which lines to remove, and in green (and a `+`) which lines to add:
Expand All @@ -42,6 +44,6 @@ Leave a comment below!

### Is someone else already working on this?

We encourage you to link to this issue by mentioning the issue # in your pull request, so we can see if someone's already started on it. **If someone seem stuck, offer them some help!** Otherwise, [take a look at some other issues you can help with](https://publiclab.github.io/community-toolbox/#r=all). Thanks!
We encourage you to link to this issue by mentioning the issue # in your pull request, so we can see if someone's already started on it. **If someone seem stuck, offer them some help!** Otherwise, [take a look at some other issues you can help with](https://code.publiclab.org/#r=all). Thanks!

(This issue was created by [First-Timers-Bot](https://github.com/hoodiehq/first-timers-bot).)
12 changes: 12 additions & 0 deletions .github/first-timers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# You can change the labels to suit your needs if "first-timers-only" is not what you are looking for.
# These are some examples.
labels:
- first-timers-only
- help wanted

#If you would like to add your own template for the issue, add an .md file to your .github folder
template: .github/first-timers-issue-template.md

# You can create the issue in a different repo than where the problem is. Just make sure you installed the bot on the configured repository.
# The issue will link back to the original repository where the contribution will be made.
#repository: repo-name
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 sleep 10
alaxalves marked this conversation as resolved.
Show resolved Hide resolved
- docker-compose run web bash -c "rake db:setup"
- docker-compose run web bash -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 -c "rake test"
- docker-compose exec web bash -l -c "rake test"
37 changes: 28 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
# Dockerfile # Mapknitter
# https://github.com/publiclab/mapknitter/
# This image deploys Mapknitter!

FROM ruby:2.4.4-stretch
MAINTAINER Sebastian Silva "[email protected]"
alaxalves marked this conversation as resolved.
Show resolved Hide resolved

LABEL This image deploys Mapknitter!
FROM debian:buster

# Set correct environment variables.
RUN mkdir -p /app
alaxalves marked this conversation as resolved.
Show resolved Hide resolved
ENV HOME /root
alaxalves marked this conversation as resolved.
Show resolved Hide resolved

# Install dependencies
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update -qq && apt-get install -y bundler default-libmysqlclient-dev ruby-rmagick libfreeimage3 libfreeimage-dev ruby-dev gdal-bin python-gdal curl libcurl4-openssl-dev libssl-dev zip nodejs ##ALSO TRIED: ruby-pg
alaxalves marked this conversation as resolved.
Show resolved Hide resolved
RUN apt-get update -qq && apt-get install -y \
bundler ruby-rmagick libfreeimage3 \
libfreeimage-dev zip nodejs gdal-bin \
curl g++ gcc autoconf automake bison \
libc6-dev libffi-dev libgdbm-dev \
libncurses5-dev libsqlite3-dev libtool \
libyaml-dev make pkg-config sqlite3 \
zlib1g-dev libgmp-dev libreadline-dev libssl-dev \
procps libmariadb-dev-compat libmariadb-dev git python-gdal \
imagemagick

# Ruby
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && curl -sSL https://get.rvm.io | bash -s stable && usermod -a -G rvm root
RUN /bin/bash -l -c ". /etc/profile.d/rvm.sh && rvm install 2.4.4 && rvm use 2.4.4 --default"

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && apt-get install -y npm
RUN npm install -g bower


# Install bundle of gems
SHELL [ "/bin/bash", "-l", "-c" ]
WORKDIR /tmp
ADD Gemfile /tmp/Gemfile
ADD Gemfile.lock /tmp/Gemfile.lock
RUN bundle install

# HOTFIX Workaround for mysql2 gem incompatibility with libmariadb-dev
RUN sed -i "s/ LONG_PASSWORD |//g" /usr/local/rvm/gems/ruby-*/gems/mysql2-*/lib/mysql2/client.rb

# Add the Rails app
WORKDIR /app
ADD . /app
alaxalves marked this conversation as resolved.
Show resolved Hide resolved
RUN bower install --allow-root
alaxalves marked this conversation as resolved.
Show resolved Hide resolved
COPY Gemfile /app/Gemfile
COPY Gemfile.lock /app/Gemfile.lock
COPY start.sh /app/start.sh

CMD [ "bash", "-l", "start.sh" ]
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ ruby "2.4.4"
gem "rails", "~>3.2"
gem 'rake', '~> 12.3.2'

gem "will_paginate", "3.1.6"
gem "will_paginate", "3.1.7"
gem "will_paginate-bootstrap"
gem "friendly_id"

# dependencies
group :dependencies do
gem 'mysql2', '~> 0.3.20'
gem 'mysql2', '< 0.4'
gem "geokit-rails", "1.1.4"
gem "image_science", "1.2.6"
gem "recaptcha", :require => "recaptcha/rails"
Expand All @@ -31,7 +31,7 @@ group :dependencies do

# asset pipelining
gem "sprockets"#, "2.12.1"
gem "sass"
gem "sass", :require => 'sass'
gem "autoprefixer-rails"
gem "uglifier"

Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ GEM
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
arel (3.0.3)
autoprefixer-rails (9.4.7)
autoprefixer-rails (9.4.8)
execjs
aws-sdk (1.5.8)
httparty (~> 0.7)
Expand Down Expand Up @@ -159,8 +159,8 @@ GEM
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
uuidtools (2.1.5)
will_paginate (3.1.6)
will_paginate-bootstrap (1.0.1)
will_paginate (3.1.7)
will_paginate-bootstrap (1.0.2)
will_paginate (>= 3.0.3)

PLATFORMS
Expand All @@ -174,7 +174,7 @@ DEPENDENCIES
geokit-rails (= 1.1.4)
image_science (= 1.2.6)
jshintrb
mysql2 (~> 0.3.20)
mysql2 (< 0.4)
oa-openid (= 0.3.2)
open_id_authentication
paperclip (~> 4.2.2)
Expand All @@ -191,11 +191,11 @@ DEPENDENCIES
test-unit
therubyracer
uglifier
will_paginate (= 3.1.6)
will_paginate (= 3.1.7)
will_paginate-bootstrap

RUBY VERSION
ruby 2.4.4p296

BUNDLED WITH
1.16.2
1.17.1
149 changes: 149 additions & 0 deletions MYSQL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# installation troubleshooting & instructions

## System Agnostic

- bundler skipping over **mysql2** gem?

```Bash

$ rm .bundle/config

$ bundle exec bundle install

```



## MacOS

**Homebrew setup:**

(Note: alternative to Homebrew is [mySQL community server](https://dev.mysql.com/downloads/mysql/5.7.html#downloads) - available for all systems)

Dependencies:

- `cmake`

- `openssl`

```Bash

$ brew install cmake

$ brew install openssl

```

Installation:

```Bash

#make sure you don't have any other versions of mysql installed
$ brew list

#if you do
$ brew uninstall <[email protected]>
$ brew unlink <[email protected]>

#install 5.7
$ brew install [email protected]

$ brew link [email protected] --force
```

Test Usage:

```Bash

# install brew services
$ brew tap homebrew/services

# cmd to run always - suggest aliasing this in your bash profile
$ brew services start [email protected]

#confirm its running
$ brew services list

# cmd to stop running
$ brew services stop [email protected]

```

Update Permissions

```Bash
# check for right permissions to the PIDs
$ ls -laF /usr/local/var/mysql/

# if the owner is root you should change it to mysql or username
$ sudo chown -R <username> /usr/local/var/mysql/

# confirm updated permissions
$ ls -laF /usr/local/var/mysql/

```

Account Setup

```Bash
# secure your account
$ mysql_secure_installation

# set password
$ mysqladmin -u root password <newpassword>
# login -- not root anymore
$ mysql -u <username> -p <password>

```

Permission issues above?

(note these commands also fix the error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2))

```Bash

$ mysql.server stop

#unset the temporary directory
$ echo $TMPDIR
$ unset TMPDIR
$ echo $TMPDIR

$ whoami

$ mysqld -initialize --verbose --user=$(whoami) --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

#restart mysql
$ mysql.server restart


$ mysql -u root

#You should now be in the mysql command line shell
mysql> SELECT User, Host, authentication_string FROM mysql.user;

mysql> rename user 'root'@'localhost' to '<yourUsername>'@'localhost';

#confirm
mysql> SELECT User, Host, authentication_string FROM mysql.user;

mysql> flush privileges;

mysql> exit

```

Reconfirm Access

(whenever want to access the mysql db locally, need to run this login first - suggest aliasing in bash profile)

```Bash

$ mysql -u <username> -p

```



## Pending: please add instructions for your respective system

13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export COMPOSE_HTTP_TIMEOUT=360

build:
cp config/database.yml.example config/database.yml
cp db/schema.rb.example db/schema.rb
docker-compose build
docker-compose run web bash -l -c "sleep 10 && rake db:setup && rake db:migrate && rake assets:precompile"

deploy-container:
docker-compose up -d

redeploy-container:
docker-compose up --force-create -d
2 changes: 2 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
References \#0000 (\<=== Add issue number here)

Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!

* [ ] tests pass -- `rake test`
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ Install rvm for Ruby management (http://rvm.io)

**Ubuntu users:** You may need to enable `Run command as a login shell` in Ubuntu's Terminal, under Profile Preferences > Title and Command. Then close the terminal and reopen it.

Then, use RVM to install version 2.1.2 of Ruby:
Then, use RVM to install version 2.4.4 of Ruby:

`rvm install 2.1.2`
`rvm install 2.4.4`

You'll also need **bower** which is available through NPM. To install NPM, you can run:

Expand All @@ -88,14 +88,14 @@ Once NPM is installed, you should be able to run:

## Installation

You'll need at least Ruby v1.9.3 (**v2.1.x** preferred)
You'll need Ruby v2.4.4 (use your local ruby version management system - RVM / rbenv / etc. - to install and set locally)

1. Download a copy of the source with `git clone https://github.com/publiclab/mapknitter.git`
2. Install gems with `bundle install` from the rails root folder. You may need to run `bundle update` if you have older gems in your environment.
3. Copy and configure config/database.yml from config/database.yml.example, using a new empty database you've created
4. Copy and configure config/config.yml from config/config.yml.example (for now, this is only for the [Google Maps API Key, which is optional](http://stackoverflow.com/questions/2769148/whats-the-api-key-for-in-google-maps-api-v3))
5. Initialize database with `bundle exec rake db:setup`
6. Enter ReCaptcha public and private keys in config/initializers/recaptcha.rb, copied from recaptcha.rb.example. To get keys, visit https://google.com/recaptcha/admin
6. Enter ReCaptcha public and private keys in config/initializers/recaptcha.rb, copied from recaptcha.rb.example. To get keys, visit https://www.google.com/recaptcha/admin/create
7. Install static assets (like external javascript libraries, fonts) with `bower install`
8. Start rails with `bundle exec passenger start` from the Rails root and open http://localhost:3000 in a web browser. (For some, just `passenger start` will work; adding `bundle exec` ensures you're using the version of passenger you just installed with Bundler.)

Expand Down
Loading