Skip to content

Commit

Permalink
Merge pull request #119 from UCLALibrary/fix-documentation-and-docker…
Browse files Browse the repository at this point in the history
…-compose

Updated README, pinned postgres version
  • Loading branch information
kjallen authored May 25, 2024
2 parents 1329985 + ff9f98c commit cf71299
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 31 deletions.
70 changes: 41 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
# Docker Development Setup

1. Install Docker ([macOS](https://docs.docker.com/docker-for-mac/install/)/[Windows](https://docs.docker.com/docker-for-windows/install/)/[Linux](https://docs.docker.com/engine/install/))
2. `.env` is populated with good defaults.
3. Install Dory: https://github.com/FreedomBen/dory
4. Configure dory: https://github.com/FreedomBen/dory#config-file
Add the following to the config-file
- Install Docker ([macOS](https://docs.docker.com/docker-for-mac/install/)/[Windows](https://docs.docker.com/docker-for-windows/install/)/[Linux](https://docs.docker.com/engine/install/))
- `.env` is populated with good defaults.
- Copy `.env` to `.env.development`
- Build project and start up

```bash
- domain: test
address: 127.0.0.1
docker compose build
docker compose up
```

5. Run dory:

```bash
dory up
```
- Visit 127.0.0.1:8000 in your browser.
- The first time the application is brought up, some database updates need to be made due to shifting dependencies

6. Build project and start up
- Identify your postgres container and run the following:

```bash
docker compose build
docker compose up
```
docker ps
# Note container id below
a320a4fabaac postgres:15 "docker-entrypoint.s…"
# Shell into container
docker exec -it [container id from above] /bin/bash
/bin/psql --username=postgres
ALTER DATABASE oral_history REFRESH COLLATION VERSION;
ALTER DATABASE oral_history_test REFRESH COLLATION VERSION;
ALTER DATABASE postgres REFRESH COLLATION VERSION;
ALTER DATABASE template0 REFRESH COLLATION VERSION;
ALTER DATABASE template1 REFRESH COLLATION VERSION;
```

7. Visit http://oralhistory.test in your browser.
8. Load database and import data
- Load database and import data

```
docker compose exec web bundle exec rake db:migrate
docker compose exec web bundle exec rake db:seed
docker compose exec web bundle exec rake import[100]
```

9. Sign into the Admin Dashboard
Navigate to https://oralhistory.test/users/sign_in
Login with default the seeded user and password at db/seeds.rb
Note you can add those ENV variable to your .env file to update
the values in one place. But deafults are set so make sure you
update for produciton environment.

10. Common Developer Recipes:
Drop into a bash console inside docker container: `docker compose exec container-name bash`. Example: `docker compose exec web bash`
Drop into a sh console inside docker container: `docker compose exec container-name sh`. Example: `docker compose exec web sh`
Drop into a rails console: `docker compose exec bundle exec rails c`
- Sign into the Admin Dashboard
Navigate to https://127.0.0.1:8000/users/sign_in
Login with default the seeded user and password at db/seeds.rb
Note you can add those ENV variable to your .env file to update
the values in one place. But deafults are set so make sure you
update for produciton environment.

- Common Developer Recipes:
Drop into a bash console inside docker container:
`docker compose exec container-name bash`
Example: `docker compose exec web bash`

Drop into a sh console inside docker container:
`docker compose exec container-name sh`
Example: `docker compose exec web sh`
Drop into a rails console:
`docker compose exec bundle exec rails c`

**Note:** The `100` in `import[100]` limits the number of assets initially loaded. You may adjust this as desired.

Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "active_support/core_ext/integer/time"

Rails.application.configure do
config.hosts << "oralhistory.test"
config.hosts << "localhost"
# disable integrity check in development
config.webpacker.check_yarn_integrity = false

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2.2'
services:
postgres:
image: postgres
image: postgres:15
env_file:
- .env
- .env.development
Expand Down

0 comments on commit cf71299

Please sign in to comment.