parent
9e9020f3ba
commit
31546d91cc
@ -0,0 +1,3 @@ |
||||
#!/bin/sh |
||||
|
||||
docker-compose -f ./docker/dev/compose.yml $* |
@ -0,0 +1,32 @@ |
||||
FROM ruby:2.6-stretch |
||||
MAINTAINER operations@openproject.com |
||||
|
||||
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"] |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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. |
Loading…
Reference in new issue