|
1 | 1 | # How to use the Dockerfile |
2 | 2 | It should be assumed that all commands should be run from the project root, unless otherwise noted. |
3 | | -Additionally, depending on your platform and how you've setup Docker, ```docker``` commands might need to be run as the ```root``` user or prefaced with ```sudo``` to work properly. |
| 3 | +Additionally, depending on your platform and how you've setup Docker, `docker` commands might need to be run as the `root` user or prefaced with `sudo` to work properly. |
4 | 4 |
|
5 | 5 | ## Quickstart |
6 | | -``` |
7 | | -docker-compose up |
| 6 | +```sh |
| 7 | +./start-server.sh |
8 | 8 | ``` |
9 | 9 | Admin Credentials: admin:development |
10 | 10 |
|
11 | 11 | User Credentials: user:development |
12 | 12 |
|
13 | 13 | ## Install Docker |
14 | | -See [https://www.docker.com/](docker.com) for instructions on installing Docker for your platform. |
| 14 | +See <https://www.docker.com/> for instructions on installing Docker for your platform. |
15 | 15 |
|
16 | 16 | ## Configure, Build, and Run |
17 | | -The dockerfile will automatically copy the config.ini.example and alembic.ini.example to config.ini and alembic.ini, respectfully. If you wish to provide your own, copy them like below and edit as you will. |
18 | | -``` |
19 | | -cp config.ini.example config.ini && cp alembic.ini.example alembic.ini |
| 17 | +The launch script will automatically copy the `config.ini.example`, `alembic.ini.example` and `logging.ini.example` to `config.ini`, `alembic.ini` and `logging.ini`, respectively. |
| 18 | +If you wish to provide your own, copy them like below and edit as you will. |
| 19 | +```sh |
| 20 | +cp config.ini.example config.ini && cp alembic.ini.example alembic.ini && cp logging.ini.example logging.ini |
20 | 21 | ``` |
21 | 22 |
|
22 | | -To create all the required containers and startup spacedock, run |
23 | | -``` |
24 | | -docker-compose up |
| 23 | +To create all the required containers and startup SpaceDock, run |
| 24 | +```sh |
| 25 | +./start-server.sh |
25 | 26 | ``` |
26 | | -This will automatically link ```your_project_root``` to ```/opt/spacedock``` on the container. |
27 | | -This means that changes you make locally to files in your project folder will be instantly synced to and reflected in the container. |
28 | | -This will also forward port 8000 of your docker contianer to port 8000 of your docker-machine, so you'll be able to browse to your local server. |
29 | | -Furthermore, this will also give the ```spacedock``` name to your container, which will make managing it easier. |
| 27 | +This will automatically link `./` to `/opt/spacedock` in the backend container, as well as `./spacedock-db` into the database container and `./storage` into the frontend container. |
| 28 | +This means that changes you make locally to files in your project folder will be instantly synced to and reflected in the container (however CSS and JS files need to be rebuilt before the changes take effect). |
| 29 | +This will also forward port 5080 of the nginx container to port 5080 of your host, so you'll be able to browse to your local server. |
| 30 | + |
| 31 | +The following containers will be started: |
| 32 | + |
| 33 | +| docker-compose service name | container name | function | |
| 34 | +| --------------------------- | -------------- | -------- | |
| 35 | +| backend | spacedock_backend_1 | Flask development server | |
| 36 | +| db | spacedock_db_1 | PostgreSQL database | |
| 37 | +| redis | spacedock_redis_1 | Redis in-memory Key-Value store (required for Celery) | |
| 38 | +| frontend | spacedock_frontend_1 | NGINX frontend acting as proxy to the backend and serving static files | |
| 39 | +| adminer | spacedock_adminer_1 | Database management UI for development and debugging | |
30 | 40 |
|
31 | | -You might run into a problem where changes to the Dockerfile are not reflected run you run ```docker-compose up```. This is expected. Run ```docker-compose rm -f && docker-compose build``` to force the containers to be rebuilt. |
| 41 | +To interact with a container using the `docker` command, you need to use the container name. |
| 42 | +To interact using `docker-compose`, you need to use the service name and be in the repository directory or any subdirectory. |
32 | 43 |
|
33 | 44 | ## Connecting |
34 | | -If you are on a mac or another environment that requires the use of docker-machine, then you must connect to the local server via that docker machine rather than localhost. |
| 45 | +If you are on macOS or another environment that requires the use of docker-machine, then you must connect to the local server via that docker machine rather than localhost. |
35 | 46 |
|
36 | | -To find out the correct IP to use in your browser, use ```docker-machine ip```. You can then browser to port 5000 of that IP and all should be well. |
| 47 | +To find out the correct IP to use in your browser, use `docker-machine ip`. You can then browse to port 5080 of that IP and all should be well. |
37 | 48 |
|
38 | 49 | There are two default accounts, an admin and a regular user: |
39 | 50 | Admin Credentials: admin:development |
40 | 51 | User Credentials: user:development |
41 | 52 |
|
42 | 53 | ## Starting and Stopping |
43 | | -If you want to stop your container without losing any data, you can simply do ```docker-compose stop```. |
44 | | -Then, to start it back up, do ```docker-compose up```. |
45 | | - |
46 | | -## Enabling Gunicorn |
47 | | -By default, the flask debug server is used to facilitate local development, as it handles serving static files better than gunicorn and has the Werkzeug debugger enabled. To enable using Gunicorn, which is recommended for a production environment, you should set the ```USE_GUNICORN``` environment variable when starting the docker container. Do so either in your user's .bashrc file or on the command-line like below. |
48 | | - |
49 | | -``` |
50 | | -USE_GUNICORN=true docker-compose up |
51 | | -``` |
| 54 | +If you want to stop your container without losing any data, you can simply do `docker-compose stop`. |
| 55 | +Then, to start it back up, do `docker-compose up`. |
52 | 56 |
|
53 | 57 | ## Odd and Ends |
54 | | -``` |
55 | | -docker exec -i -t spacedock bash # Start a bash shell in the spacedock container |
| 58 | +```sh |
| 59 | +docker-compose exec backend /bin/bash # Start a bash shell in the backend container |
56 | 60 | ``` |
0 commit comments