Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Made docker dev setup more accessible, added Quickstart to docs.

Markus Kahlbe2c5ed3475d
diff --git a/bin/compose b/bin/compose
new file mode 100755
index 00000000000..2705f6ff11c
--- /dev/null
+++ b/bin/compose
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+set -e
+
+if [ -f .env ]; then
+ export `grep -v '^#' .env | xargs`
+else
+ export DEV_UID=$(id -u) DEV_GID=$(id -g) LOCAL_DEV_CHECK=1
+fi
+
+COMPOSE_FILE=docker-compose.yml
+
+if [ $# -eq 0 ]; then
+ echo "Usage: bin/compose <command> [args*]"
+ echo
+ echo "Commands:"
+ echo " setup - Has to be run once intially. Installs backend and frontend dependencies. "
+ echo " start - Starts both backend and frontend in the background. Acccess via http://localhost:3000/ by default."
+ echo " run - Starts the frontend in the backround and backend in the foreground. Useful for debugging using pry."
+ echo " * - Everything else will be passed straight to \`docker-compose\`."
+ echo
+
+ exit 1
+elif [[ "$@" = "start" ]]; then
+ # backend will be started automatically as a dependency of the frontend
+ docker-compose -f $COMPOSE_FILE up -d frontend
+elif [[ "$@" = "run" ]]; then
+ docker-compose -f $COMPOSE_FILE up -d frontend
+ docker-compose -f $COMPOSE_FILE stop backend
+ docker-compose -f $COMPOSE_FILE run -p ${PORT:-3000}:3000 backend # run backend in TTY so you can debug using pry for instance
+elif [[ "$1" = "setup" ]]; then
+ docker-compose -f $COMPOSE_FILE run backend setup
+ yes no | docker-compose -f $COMPOSE_FILE run frontend npm install
+else
+ docker-compose -f $COMPOSE_FILE $*
+fi
diff --git a/docker-compose.yml b/docker-compose.yml
index 6b282700c61..3ffd0bcd5e5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -39,9 +39,9 @@ services:
volumes:
- "pgdata:/var/lib/postgresql/data"
environment:
- POSTGRES_USER: ${DB_USERNAME}
- POSTGRES_PASSWORD: ${DB_PASSWORD}
- POSTGRES_DB: ${DB_DATABASE}
+ POSTGRES_USER: ${DB_USERNAME:-postgres}
+ POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
+ POSTGRES_DB: ${DB_DATABASE:-openproject}
networks:
- network
@@ -66,7 +66,7 @@ services:
RAILS_CACHE_STORE: memcache
OPENPROJECT_CACHE__MEMCACHE__SERVER: cache:11211
OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
- DATABASE_URL: postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}
+ DATABASE_URL: postgresql://${DB_USERNAME:-postgres}:${DB_PASSWORD:-postgres}@${DB_HOST:-db}:${DB_PORT:-5432}/${DB_DATABASE:-openproject}
volumes:
- ".:/home/dev/openproject"
- "opdata:/var/openproject/assets"
diff --git a/docs/development/development-environment-docker/README.md b/docs/development/development-environment-docker/README.md
index 23c7dc8df02..5bc1d80ceb4 100644
--- a/docs/development/development-environment-docker/README.md
+++ b/docs/development/development-environment-docker/README.md
@@ -2,6 +2,28 @@
The quickest way to get started developing OpenProject is to use the docker setup.
+## Requirements
+
+* docker
+
+And nothhing else!
+
+## Quickstart
+
+To get right into it and just start the application you can just do the following:
+
+```
+git clone https://github.com/opf/openproject.git
+cd openproject
+bin/compose setup
+bin/compose start
+```
+
+Once the containers are done booting you can access the application under http://localhost:3000.
+
+If there is an `.env` file (see below) `bin/compose` will source it.
+More details and options follow in the next section.
+
## Setup
### 1) Checkout the code
@@ -17,7 +39,7 @@ This will checkout the dev branch in `openproject`. **Change into that directory
If you have OpenProject checked out already make sure that you do not have a `config/database.yml`
as that will interfere with the database connection inside of the docker containers.
-### 3) Configure environment
+### 2) Configure environment
Copy the env example to `.env`
@@ -28,7 +50,7 @@ cp .env.example .env
Afterwards, set the environment variables to your liking. `DEV_UID` and `DEV_GID` are required to be set so your project
directory will not end up with files owned by root.
-### 2) Setup database and install dependencies
+### 3) Setup database and install dependencies
```
# Start the database. It needs to be running to run migrations and seeders
@@ -41,7 +63,7 @@ docker-compose run frontend npm i
docker-compose run backend setup
```
-### 3) Start the stack
+### 4) Start the stack
The docker compose file also has the test containers defined. The easiest way to start only the development stack, use
@@ -113,3 +135,20 @@ file to see which port each browser container is exposed on. The password is `se
Running the docker images will change some of your local files in the mounted code directory.
The file `frontend/npm-shrinkwrap.json` may be modified.
You can just reset these changes if you want to commit something or pull the latest changes.
+
+## Debugging
+
+It's common to just start a debugger whithin ruby code using `binding.pry`.
+This **does not work** with the application running as shown above.
+
+If you want to be able to do that, you can, however, simply run the following:
+
+```
+bin/compose run
+```
+
+If the frontend container is not running yet, it will be started.
+If the backend container is already running, it will be stopped.
+Instead it will be started in the foreground.
+This way you can debug using pry just as if you had started the server locally using `rails s`.
+You can stop it simply with Ctrl + C too.