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

docker-based dev environment

Markus Kahl5c07f7bd9514
diff --git a/bin/compose b/bin/compose
new file mode 100755
index 00000000000..bd7512d4141
--- /dev/null
+++ b/bin/compose
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker-compose -f ./docker/dev/compose.yml $*
diff --git a/docker/dev/Dockerfile.dev b/docker/dev/Dockerfile.dev
new file mode 100644
index 00000000000..976761d07be
--- /dev/null
+++ b/docker/dev/Dockerfile.dev
@@ -0,0 +1,32 @@
+FROM ruby:2.6-stretch
+MAINTAINER [email protected]
+
+ENV USER=dev
+ENV RAILS_ENV=development
+
+ENV NODE_VERSION "10.15.0"
+ENV BUNDLER_VERSION "2.0.2"
+
+RUN curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz | tar xzf - -C /usr/local --strip-components=1
+
+RUN useradd -d /home/$USER -m $USER
+WORKDIR /home/$USER
+
+RUN gem install bundler --version "${bundler_version}" --no-document
+
+RUN apt-get update -qq && \
+ DEBIAN_FRONTEND=noninteractive apt-get install -y \
+ postgresql-client \
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
+
+COPY scripts/seeder bin/seeder
+COPY scripts/backend bin/backend
+COPY scripts/frontend bin/frontend
+
+EXPOSE 3000 4200
+
+VOLUME ["/usr/local/bundle", "/home/$USER/openproject"]
+
+WORKDIR /home/$USER/openproject
+
+ENTRYPOINT ["/bin/sh", "-c"]
diff --git a/docker/dev/compose.yml b/docker/dev/compose.yml
new file mode 100644
index 00000000000..bc9b50ad0bd
--- /dev/null
+++ b/docker/dev/compose.yml
@@ -0,0 +1,82 @@
+version: "3.7"
+
+networks:
+ frontend:
+ backend:
+
+volumes:
+ pgdata:
+ opdata:
+ bundle:
+
+x-op-restart-policy: &restart_policy
+ restart: unless-stopped
+x-op-image: &image
+ build:
+ context: .
+ dockerfile: Dockerfile.dev
+ image:
+ openproject/dev:latest
+x-op-app: &app
+ <<: *image
+ <<: *restart_policy
+ environment:
+ - "RAILS_ENV=development"
+ - "RAILS_CACHE_STORE=memcache"
+ - "OPENPROJECT_CACHE__MEMCACHE__SERVER=cache:11211"
+ - "OPENPROJECT_RAILS__RELATIVE__URL__ROOT=${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
+ - "DATABASE_URL=postgresql://postgres:postgres@db/openproject"
+ volumes:
+ - "${OPENPROJECT_HOME:?Please set OPENPROJECT_HOME to the OpenProject root folder}:/home/dev/openproject"
+ - "opdata:/var/openproject/assets"
+ - "bundle:/usr/local/bundle"
+ depends_on:
+ - db
+ - cache
+
+services:
+ db:
+ image: postgres:9
+ <<: *restart_policy
+ stop_grace_period: "3s"
+ volumes:
+ - "pgdata:/var/lib/postgresql/data"
+ environment:
+ - POSTGRES_PASSWORD=postgres
+ - POSTGRES_DB=openproject
+ networks:
+ - backend
+
+ cache:
+ image: memcached
+ <<: *restart_policy
+ networks:
+ - backend
+
+ backend:
+ <<: *app
+ command: "/home/dev/bin/backend"
+ ports:
+ - "3000:3000"
+ networks:
+ - backend
+ depends_on:
+ - seeder
+
+ frontend:
+ <<: *app
+ command: "/home/dev/bin/frontend"
+ ports:
+ - "4200:4200"
+ networks:
+ - frontend
+ - backend
+ depends_on:
+ - seeder
+
+ seeder:
+ <<: *app
+ command: "/home/dev/bin/seeder"
+ restart: on-failure
+ networks:
+ - backend
diff --git a/docker/dev/scripts/backend b/docker/dev/scripts/backend
new file mode 100755
index 00000000000..2a8ce68c83e
--- /dev/null
+++ b/docker/dev/scripts/backend
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+echo "Waiting for bundle installation and db setup to finish..."
+touch tmp/.seeding_status
+(tail -f -n0 tmp/.seeding_status & ) | timeout 240 grep -q done
+
+if [ ! $? -eq 0 ]
+then
+ echo "DB not ready"
+
+ exit 1
+fi
+
+rm -rf tmp/*
+
+bundle exec rails server thin -b 0.0.0.0
diff --git a/docker/dev/scripts/frontend b/docker/dev/scripts/frontend
new file mode 100755
index 00000000000..ec651a9be3f
--- /dev/null
+++ b/docker/dev/scripts/frontend
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+echo "Waiting for bundle installation and db setup to finish..."
+touch tmp/.seeding_status
+(tail -f -n0 tmp/.seeding_status & ) | timeout 240 grep -q done
+
+if [ ! $? -eq 0 ]
+then
+ echo "DB not ready"
+
+ exit 1
+fi
+
+bin/setup_dev \
+ && cd frontend \
+ && npm install \
+ && node \
+ --max_old_space_size=8096 ./node_modules/@angular/cli/bin/ng serve \
+ --host 0.0.0.0 --port 4200 --public-host http://locahost:4200
diff --git a/docker/dev/scripts/seeder b/docker/dev/scripts/seeder
new file mode 100755
index 00000000000..9f1c57118cf
--- /dev/null
+++ b/docker/dev/scripts/seeder
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+bundle install \
+ && bundle exec rake db:create db:migrate \
+ && bundle exec rake db:seed \
+ && echo done > tmp/.seeding_status
diff --git a/docs/development/README.md b/docs/development/README.md
index 154e2f3a0ec..05fd6c5889f 100644
--- a/docs/development/README.md
+++ b/docs/development/README.md
@@ -16,6 +16,10 @@ We eat our own ice cream so we use OpenProject for roadmap planning and team col
- [Reporting a bug](https://www.openproject.org/development/report-a-bug/)
- [Submit a feature idea](https://www.openproject.org/development/submit-feature-idea/)
+## Development Environment
+
+Take a look at the bottom under Additional resources to see how to setup your development environment.
+
## Branching model
The main development branch for upcoming releases is `dev`. If in doubt, create your pull request against `dev`. All new features, gem updates and bugfixes for the upcoming release should go into the `dev` branch.
@@ -107,9 +111,9 @@ This code of conduct is adapted from the [Contributor Covenant](http://contribut
-## OpenProject Contributor License Agreement (CLA)
+## OpenProject Contributor License Agreement (CLA)
-If you want to contribute to OpenProject, please make sure to accept our Contributor License Agreement first. The contributor license agreement documents the rights granted by contributors to OpenProject.
+If you want to contribute to OpenProject, please make sure to accept our Contributor License Agreement first. The contributor license agreement documents the rights granted by contributors to OpenProject.
[Read and accept the Contributor License Agreement here.](http://openproject.org/contributor-license-agreement/)
@@ -118,9 +122,9 @@ If you want to contribute to OpenProject, please make sure to accept our Contrib
* [Development environment for Ubuntu 16.04.](development-environment-ubuntu)
* [Development environment for Mac OS X](development-environment-osx)
+* [Development environment using docker](development-environment-docker)
* [Developing Plugins](create-openproject-plugin)
* [Running Tests](running-tests)
* [API Documentation](/api/)
* [Report a Bug](report-a-bug)
-
diff --git a/docs/development/development-environment-docker/README.md b/docs/development/development-environment-docker/README.md
new file mode 100644
index 00000000000..b0dd3d0de7a
--- /dev/null
+++ b/docs/development/development-environment-docker/README.md
@@ -0,0 +1,59 @@
+# OpenProject development setup via docker
+
+The quickest way to get started developing OpenProject is to use the docker setup.
+
+## Setup
+
+### 1) Checkout the code
+
+First you will need to checkout the code as usual.
+
+```
+git clone https://github.com/opf/openproject.git
+```
+
+This will checkout the dev branch in `openproject`. Change into that directory.
+
+### 2) Execute the setup
+
+```
+export OPENPROJECT_HOME=`pwd`
+
+bin/compose up
+```
+
+This process can take quite a long time on the first run where all gems are installed for the first time.
+However, these are cached in a docker volume. Meaning that from the 2nd run onwards it will start a lot quicker.
+
+Wait until you see `frontend_1 | : Compiled successfully.` and `backend_1 | => Rails 6.0.2.2 application starting in development http://0.0.0.0:3000` in the logs.
+This means both frontend and backend have come up successfully.
+You can now access OpenProject under http://localhost:3000.
+
+Again the first request to the server can take some time too.
+But subsequent requests will be a lot faster.
+
+Changes you make to the code will be picked up automatically.
+No need to restart the containers.
+
+## Docker
+
+You can stop the processes via Ctrl + C. You can also run everything in the background by adding the `-d` option as in `bin/compose up -d`. In that case you'll still be able to see the logs using `docker logs` with the respective container name.
+You can see the started containers using `docker ps`.
+
+### Volumes
+
+There are volumes for
+
+ * the attachments (`_opdata`)
+ * the database (`_pgdata`)
+ * the bundle (rubygems) (`_bundle`)
+
+This means these will stay between runs even if you stop and restart the containers.
+If you want to reset the data you can delete the docker volumes via `docker volume rm`.
+
+## Local files
+
+Running the docker images will change some of your local files in the mounted code directory.
+The `tmp` directory will be deleted on start of the backend container.
+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.