mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 00:24:42 +08:00
Beautify theh production setup
parent
4e04c6111c
commit
6530eec456
1 changed files with 29 additions and 14 deletions
|
@ -176,30 +176,45 @@ The following table describes all available environmental variables for sciNote
|
|||
| **Misc** | | |
|
||||
| NEW_RELIC_LICENSE_KEY | No | [New Relic](https://newrelic.com/) code metrics license key, in case you want to log code metrics with New Relic service. |
|
||||
|
||||
## Running inside Docker containers in production mode with docker-compose
|
||||
## Production mode (in Docker containers)
|
||||
|
||||
New functionality for running in production mode was introduces in SciNote version 1.10.0.
|
||||
In order to run SciNote application in production inside Docker you'll need docker engine version 1.12.0+ itself and docker-compose with version 1.6.0+.
|
||||
Also you'll need to set environment variables in `production.env` file, variables are the same as described in [Environmental variables section](#user-content-environmental-variables), only format of records is slightly different, use `KEY="VALUE"` record format. Only difference is DATABASE_URL=postgresql://postgres@db/scinote_production, should be set without quotes. This variable is used to configure database connection and by default it contains credentials to connect to PostgreSQL database inside `db` container, you will need to change this variable if you decide to use another DB or set password for default db user.
|
||||
You can generate default minimal production.env file with `make config-production`, it will generate SECRET_KEY_BASE and PAPERCLIP_HASH_SECRET as well.
|
||||
### Running server in production mode
|
||||
|
||||
After setting all required variables you need to build docker image with `make docker-production`, it will install all needed Gems and pre-compile assets.
|
||||
New functionality for running in production mode was introduced with sciNote version 1.10.0. In order to run sciNote application in production inside Docker you'll need the following:
|
||||
|
||||
* docker engine (version 1.12.0+),
|
||||
* docker-compose (version 1.6.0+).
|
||||
|
||||
You'll also need to set environment variables in `production.env` file; variables are the same as described in [Environmental variables section](#user-content-environmental-variables), the only differences are:
|
||||
|
||||
* format of records is changed - use `KEY="VALUE"` record format;
|
||||
* you should set `DATABASE_URL=postgresql://postgres@db/scinote_production` without quotation marks.
|
||||
|
||||
The mentioned variable is used to configure database connection and by default it contains credentials to connect to the PostgreSQL database inside `db` container; you will need to change this variable if you decide to use another DB or set password for default db user.
|
||||
|
||||
You can generate default (minimal) `production.env` file with the following command: `make config-production`. This command will also generate `SECRET_KEY_BASE` and `PAPERCLIP_HASH_SECRET` variables automatically.
|
||||
|
||||
After setting all the required variables you need to build the Docker image with `make docker-production`; this command will install all needed Gems and precompile assets.
|
||||
|
||||
Now, when build is finished, it is needed to initialize the database(if you do a new install). It can be done with `make database-production`. Now database is initialized and running inside `scinote_db_production` container. This container is configured to keep all DB files in the persistent Docker volume named `scinote_production_postgres`, by default it is placed in /var/lib/docker/volumes of the host system. There is also another persistent docker volume `scinote_production_files`, it is used for storing generated and uploaded files if you configure local file storage. These volumes will be kept in case you delete containers, but `docker rm` with `-v` flag will also delete volumes. Also keep in mind that `docker-compose down` with `-v` key also deletes volumes.
|
||||
When the above build is finished, database needs to be initialized (if you're performing a new install). This can be done by running `make database-production`. This will initialize the database and start a running process; the database will be hosted in the `scinote_db_production` container. This container is configured to keep all database files in the persistent Docker volume named `scinote_production_postgres`, which is (by default) placed in `/var/lib/docker/volumes` of the host system.
|
||||
|
||||
Background jobs worker will be running in the separate container called 'scinote_jobs_production'.
|
||||
There is also another persistent Docker volume called `scinote_production_files`; this container is used for storing generated and uploaded files if you configure local file storage.
|
||||
|
||||
Now you can start SciNote with `docker-compose -f ./docker-compose.production.yml up`. Use `docker-compose -f ./docker-compose.production.yml up -d` to start it in the background mode. Please consult docker-compose documentation for the rest of supported commands.
|
||||
All these volumes will be kept safe in case you delete your Docker containers. Running `docker rm` with `-v` flag, however, will also delete these volumes (same thing happens if you run `docker-compose down` with `-v` flag).
|
||||
|
||||
So basically sequence of commands to setup SciNote(for fresh install) is:
|
||||
Background jobs worker will be running in another separate container called `scinote_jobs_production`.
|
||||
|
||||
`make config-production`
|
||||
Now (finally), you can start sciNote with the following command: `docker-compose -f ./docker-compose.production.yml up`. Or you can use `docker-compose -f ./docker-compose.production.yml up -d` to start the server in background mode. Please consult `docker-compose` documentation for the rest of supported commands.
|
||||
|
||||
`make docker-production`
|
||||
In short, the sequence of commands to setup sciNote (for fresh install) would be:
|
||||
|
||||
`make database-production`
|
||||
```bash
|
||||
make config-production
|
||||
make docker-production
|
||||
make database-production
|
||||
|
||||
`docker-compose -f ./docker-compose.production.yml up`
|
||||
docker-compose -f ./docker-compose.production.yml up
|
||||
```
|
||||
|
||||
### Migrating to the new production setup
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue