Skip to content

Commit

Permalink
Merge pull request #740 from ChicagoWorldcon/main
Browse files Browse the repository at this point in the history
Push main doc changes to staging
  • Loading branch information
balen authored Oct 4, 2022
2 parents 6122b1e + d44ce38 commit c5835ac
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 122 deletions.
148 changes: 143 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
Rails 6.x
Vue.js

### Devise
We are using encrypted secrets for now. For dev please request key file.

## Note On Local Development

## Set up your environment
Expand All @@ -26,6 +23,11 @@ export POSTGRES_USER=yourdbuser
export POSTGRES_PASSWORD=yourpassword
export DEVISE_SECRET=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
export SIDEKIQ_REDIS_URL=redis://localhost:6379/0
export SMTP_PORT=10025
export SMTP_SERVER=127.0.0.1
export HOSTNAME=localhost
export HOSTPORT=3000
export [email protected]
```

The USER and PASSWORD will be used by the docker scripts to create an instance of the database
Expand All @@ -34,8 +36,7 @@ unimportant and can be used as-is.

DEVISE_SECRET is used by Ruby for encryption. Any long string will do. This one works fine.

Redis is not running at the default port, so Sidekiq needs to be told where it is.

Redis is running in a container, so Sidekiq and Rails needs to be told where it is.

If you are installing this on a Windows machine, you may need to run the
following command:
Expand Down Expand Up @@ -117,3 +118,140 @@ docker volume create --name=node_modules_sidekiq
```

Now you can run `docker-compose`

# Notes for Production

There is a sample docker compose file `docker-compose-prod.yml` that can be used to base a prodction instance on. It assumes
that the Postgres DB is running outside of docker. If you want to run the DB in a container have a look at the Staging
compose file for an example of how that is done.

There are automated builds happening in Github and docker containers are stored in the Github repo. One for each branch (main, staging, development)
as well as a "latest" which is built when a release tag is done. To pull them use one of the following commands:

```
docker pull ghcr.io/chicagoworldcon/planorama:main
docker pull ghcr.io/chicagoworldcon/planorama:staging
docker pull ghcr.io/chicagoworldcon/planorama:development
docker pull ghcr.io/chicagoworldcon/planorama:latest
```

Latest will be the last build based on a tagged release.

## Directory mappings

We map the log directories from the containers to teh system directories `/var/log/planorama/web` and `/var/log/planorama/sidekiq`,
see the mapping under the web and sidekiq containers, they have a line like the following to do the mapping:

```
- /var/log/planorama/web:/opt/planorama/log
```

## Redis data

Redis data needs to be persistent between runs of the docker container. You will need to create a volume using the
docker command as follows:

```
docker volume create --name=redis-data
```

## Environment

The containers rely on enironment variables. The docker file loads the environment from a file,
which is specified via a line as follows:

```
- "/opt/chicago/etc/planorama.env"
```

change this to what is appropriate for your system.

The file should contain lines like the following with values appropriate to your
installation:

```
HOSTNAME=planorama.mycon.org
RAILS_ENV=production
RAILS_LOG_TO_STDOUT=true
RAILS_LOG_LEVEL=info
DEVISE_SECRET=
DB_HOST=
DB_NAME=
POSTGRES_USER=
POSTGRES_PASSWORD=
[email protected]
SMTP_SERVER=
SMTP_PORT=
SMTP_USER_NAME=
SMTP_PASSWORD=
SIDEKIQ_REDIS_URL=redis://redis:6379/0
# the sidekiq user and password are optional
# SIDEKIQ_USER=sidekiq
# SIDEKIQ_PASSWORD=
```

Generate a secret key for devise using the following

```
bundle exec rake secret
```

and set that as the value for the env variable

## Event Settings

Once you have an instance running you will need to do the following

1. create an initial user
2. login and setup the event Settings

### Create initial user

You can run a shell in the rails docker container and create a user as follows:

Run a shell in the web docker container:
```
docker exec -it planorama_web_1 sh
```

Run the rails console

```
bin/rails c
```

Create a person/user from within the rails console. Set the name, password and email to
match what you need:

```
p = Person.create(
name: 'admin',
password: 'StrongPassword'
)
EmailAddress.create(
person: p,
isdefault: true,
email: '[email protected]',
is_valid: true
)
ConventionRole.create(
person: p,
role: ConventionRole.roles[:admin]
)
```

### Event Settings

In the Admin page you will see an Event Settings panel, open that and set at least the following:

- Email From Address
- Email reply to Address
- Convention Timezone
- Convention start and end times
23 changes: 13 additions & 10 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
# This is the dev version of the docker compose
# this is overlaid on the docket compose for dev environments
#
# docker-compose -p plano-dev -f docker-compose-dev.yml up
# NOTE:
# You will need to create volumes for the data to be persistent between runs
# docker volume create --name=pgdata
# docker volume create --name=redis-data
# docker volume create --name=node_modules
# docker volume create --name=node_modules_sidekiq
#
# docker-compose -p plano-dev -f docker-compose-dev.yml up --build
#
# docker-compose -p plano-dev -f docker-compose-dev.yml up --build -d
# NOTE:
# start the docker containers:
# docker-compose -p plano-dev -f docker-compose-dev.yml up
# build and start the docker containers:
# docker-compose -p plano-dev -f docker-compose-dev.yml up --build
# build and start the docker containers and detach the processes:
# docker-compose -p plano-dev -f docker-compose-dev.yml up --build -d
#
version: "3.7"

#
# docker volume create --name=pgdata
# docker volume create --name=redis-data
# docker volume create --name=node_modules
# docker volume create --name=node_modules_sidekiq
#
volumes:
pgdata:
external: true
Expand Down
31 changes: 0 additions & 31 deletions docker-compose-pg.yml

This file was deleted.

81 changes: 42 additions & 39 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,73 @@
#
# This is the dev version of the docker compose
# This is sample docker file for use in a prod environment
#
# docker-compose -f docker-compose-prod.yml up --build
# NOTE:
# You will need to create the redis-data volumes:
# docker volume create --name=redis-data
#
# With a local postgres
# docker-compose -p plano-prod -f docker-compose-prod.yml -f docker-compose-pg.yml up
# NOTE: if you want to run postgres in a container have a look at the staging compose file
# you will need to set the links for web and sidekiq accordingling and also set up
# an external volume for postgres data
#
# docker volume create --name=pgdata
#

version: "3.7"

volumes:
redis-data:
# box: {} # used for the bundler, persistent store between runs

services:
redis:
image: redis:alpine
restart: always
volumes:
- redis-data:/data
#
# NOTE:
# .enrc set ths env variables for
# DB_PORT
# POSTGRES_USER
# POSTGRES_PASSWORD
#
planorama:
# image: planorama:production
build:
context: .
dockerfile: Dockerfile-prod
env_file:
- .envrc
environment:
- DB_HOST=postgres
- RAILS_ENV=production
- NODE_ENV=production
command: /opt/planorama/script/planorama_start.sh
web:
command: "/opt/planorama/script/planorama_start.sh"
# planorama:latest for latest release (tagged)
# planorama:main for latest build of main branch
image: ghcr.io/chicagoworldcon/planorama:latest
ports:
- "127.0.0.1:3000:3000"
volumes:
# NOTE: this will need to reflect local system
- /var/log/planorama/web:/opt/planorama/log
- type: tmpfs
target: /opt/planorama/tmp
ports:
- "3000:3000"
target: /app/tmp
environment:
- PGID=1005
- PUID=1001
- RAILS_ENV=production
- NODE_ENV=production
env_file:
# NOTE: this will need to reflect local system
- "/opt/chicago/etc/planorama.env"
depends_on:
- redis
links:
- redis
restart: always

planorama-sidekiq:
# image: planorama:production
build:
context: .
dockerfile: Dockerfile-prod
env_file:
- .envrc
environment:
- DB_HOST=postgres
- RAILS_ENV=production
- NODE_ENV=production
command: /opt/planorama/script/planorama_sidekiq.sh
command: "/opt/planorama/script/planorama_sidekiq.sh"
# See above note re which image to use
image: ghcr.io/chicagoworldcon/planorama:latest
volumes:
# NOTE: this will need to reflect local system
- /var/log/planorama/sidekiq:/opt/planorama/log
- type: tmpfs
target: /opt/planorama/tmp
target: /app/tmp
environment:
- PGID=1005
- PUID=1001
- RAILS_ENV=production
- NODE_ENV=production
env_file:
# NOTE: this will need to reflect local system
- "/opt/chicago/etc/planorama.env"
depends_on:
- redis
links:
- redis
restart: always
Loading

0 comments on commit c5835ac

Please sign in to comment.