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

Update docker config #700

Merged
merged 4 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 3 additions & 10 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,8 @@ To get started using the application with docker,
2. Install [docker-compose](https://docs.docker.com/compose/install/)
3. Clone the repository, and open the repository folder in your favorite command line or terminal application.
4. From within the repository, navigate to the `/docker/development` folder. If you are in the right folder, you will see a file named `docker-compose.yml`.
5. Run
```bash
docker-compose run app '/usr/local/bin/rake' secret \
| echo "SECRET_KEY_BASE=$(tail -1 -)" > .env
```
to give rails the information it needs to be able to launch
6. Now you should be able to run `docker-compose up -d`. This will start the application in daemon mode, which means that the server will keep running in the background. If you navigate to `localhost:3000` in your browser, you will see an error. This is normal, and it means that you still need to setup the database.
7. To setup the database, you can run
5. Now you should be able to run `docker-compose up -d`. This will start the application in daemon mode, which means that the server will keep running in the background. If you navigate to `localhost:3000` in your browser, you will see an error. This is normal, and it means that you still need to setup the database.
6. To setup the database, you can run
```bash
docker-compose run \
-e SYSTEM_EMAIL="theemailyouwanttouse@example.com" \
Expand All @@ -194,7 +188,7 @@ To get started using the application with docker,
```
This will setup the database and create a default admin user with the email and password as specified by the `SYSTEM_EMAIL` and `SYSTEM_PASSWORD` environment variables you passed to `docker-compose` with the `-e` option. If you don't want to create the default user, you can just run `docker-compose run app db:prepare` and create the account using the sign up option on the website.

8. You should now be able to reload `localhost:3000` in your browser. If everything went well, the website should appear and be functional. You can sign in using the email and password you set in the previous step. This docker compose also setups an a `mailcatcher` server, which you can access at `localhost:1080`. All emails will be delivered to mailcatcher, which should allow you to setup user accounts.
7. You should now be able to reload `localhost:3000` in your browser. If everything went well, the website should appear and be functional. You can sign in using the email and password you set in the previous step. This docker compose also setups an a `mailcatcher` server, which you can access at `localhost:1080`. All emails will be delivered to mailcatcher, which should allow you to setup user accounts.

**NOTE** Do not use this method in production! This is for **testing & development only** the configuration used with in this docker-compose file is highly insecure and should never be exposed to the public internet.

Expand All @@ -204,5 +198,4 @@ Also, if you would like docker-compose to run in daemon mode (which means that i

**NOTE** the application will save its state between successive invocations of `docker-compose up --build`. This means that if you make changes to the database - for example by adding content or users - then those changes will persist the next time you start the application with `docker-compose`. You can wipe all the state of the application and all the services (including the postgres database) attached to it by running `docker-compose down --volumes --remove-orphans`. In particular, you may need to do this if you are making breaking changes to the database structure, or if you have corrupted something somehow. However, do be careful, because this will delete **all** the state saved in the application and database - and there is no way to retrieve it. So make sure you back up anything you want to save before running the command.


([Return to README.md](README.md))
56 changes: 0 additions & 56 deletions config/environments/docker-development.rb

This file was deleted.

1 change: 0 additions & 1 deletion docker/development/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ ENV RAILS_ENV='' \
POSTGRES_PASSWORD='' \
POSTGRES_USER='postgres' \
POSTGRES_DB='' \
SECRET_KEY_BASE='' \
EMAIL_PORT='' \
EMAIL_HOST='' \
EMAIL_FROM_ADDR='' \
Expand Down
32 changes: 24 additions & 8 deletions docker/development/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,39 @@ services:
dockerfile: ./docker/development/app/Dockerfile
args:
APP_PORT: *APP_PORT
user: "${UID}"
ports:
- target: *APP_PORT
published: *APP_PORT
volumes:
- ../..:/usr/src/app
- gem_cache:/usr/local/bundle/gems
- node_modules:/usr/src/app/node_modules
depends_on:
- db
- email
environment:
<<: *x-shared-postgres-environment
<<: *x-email-defaults
RAILS_ENV: docker-development
RAILS_ENV: development
Copy link
Collaborator

Choose a reason for hiding this comment

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

Such a small diff causing much loss of hair!

POSTGRES_HOST: db
# You can set this by running
# rake secret
# The resulting key should be placed in a .env file
# in this directory, or you can pass it to
# docker-compose up --build -e SECRET_KEY_BASE=...
# Otherwise the database setup step will fail
SECRET_KEY_BASE: "${SECRET_KEY_BASE}"

test:
build:
context: ../..
dockerfile: ./docker/development/app/Dockerfile
user: "${UID}"
depends_on:
- db
- email
environment:
<<: *x-shared-postgres-environment
<<: *x-email-defaults
RAILS_ENV: test
POSTGRES_HOST: db
command: bundle exec rspec

volumes:
db:
gem_cache:
node_modules: