Updated local development docker setup

There are now separate containers for testing purposes, and the frontend container is a node-only image. Containers run
with a user that has the current user id and gid, making sure that any files that are installed by bundler or npm are
user-owned.

Selenium tests can be ran, but not all of them work yet.
pull/8801/head
Benjamin Bädorf 4 years ago
parent 5c6e29862f
commit fbf375d480
No known key found for this signature in database
GPG Key ID: 4406E80E13CD656C
  1. 1
      .gitignore
  2. 5
      bin/compose
  3. 3
      bin/setup_dev
  4. 32
      docker/dev/Dockerfile.dev
  5. 47
      docker/dev/backend/Dockerfile
  6. 7
      docker/dev/backend/scripts/run-app
  7. 7
      docker/dev/backend/scripts/seed
  8. 105
      docker/dev/compose.yml
  9. 20
      docker/dev/frontend/Dockerfile
  10. 16
      docker/dev/scripts/backend
  11. 19
      docker/dev/scripts/frontend
  12. 6
      docker/dev/scripts/seeder
  13. 2
      frontend/package.json
  14. 6
      frontend/scripts/link_plugin_placeholder.js

1
.gitignore vendored

@ -54,6 +54,7 @@ npm-debug.log*
/app/assets/javascripts/editor/*
/app/assets/javascripts/locales/*.*
/frontend/src/locales/*.js
/modules/*/frontend/module/module
/config/additional_environment.rb
/config/configuration.yml
/config/database.yml

@ -1,3 +1,8 @@
#!/bin/sh
set -e
export DEV_UID=$(id -u)
export DEV_GID=$(id -g)
docker-compose -f ./docker/dev/compose.yml $*

@ -11,9 +11,6 @@ printf "Bundling rails dependencies ... "
try 'bundle install > log/setup_dev.log'
echo "done."
echo "Installing node_modules ... "
try 'npm install --no-shrinkwrap >> log/setup_dev.log'
echo "Linking plugin modules"
try 'bundle exec rake openproject:plugins:register_frontend >> log/setup_dev.log'

@ -1,32 +0,0 @@
FROM ruby:2.7.1-buster
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,47 @@
FROM ruby:2.7.1-buster as develop
MAINTAINER operations@openproject.com
ARG DEV_UID=1000
ARG DEV_GID=1001
ENV USER=dev
ENV RAILS_ENV=development
ENV BUNDLER_VERSION "2.0.2"
RUN useradd -d /home/$USER -m $USER
RUN usermod -u $DEV_UID $USER
RUN groupmod -g $DEV_GID $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
COPY ./backend/scripts/seed /usr/sbin/seed
COPY ./backend/scripts/run-app /usr/sbin/run-app
EXPOSE 3000
VOLUME ["/usr/local/bundle", "/home/$USER/openproject"]
WORKDIR /home/$USER/openproject
USER $USER
ENTRYPOINT ["/bin/sh", "-c"]
####### Testing image below #########
FROM develop as test
USER root
RUN apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
chromium
USER $USER

@ -0,0 +1,7 @@
#!/bin/sh
set -e
set -u
rm -rf "${OPENPROJECT_STORAGE_TMP__PATH:-tmp}/*"
bundle exec rails server thin -b 0.0.0.0

@ -0,0 +1,7 @@
#!/bin/sh
set -e
bundle install
bundle exec rake db:create db:migrate
bundle exec rake db:seed

@ -3,36 +3,25 @@ version: "3.7"
networks:
frontend:
backend:
test:
volumes:
pgdata:
opdata:
bundle:
pgdata-test:
x-op-restart-policy: &restart_policy
restart: unless-stopped
x-op-build: &build
context: .
dockerfile: ./backend/Dockerfile
args:
DEV_UID: $DEV_UID
DEV_GID: $DEV_GID
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:
@ -42,8 +31,8 @@ services:
volumes:
- "pgdata:/var/lib/postgresql/data"
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=openproject
POSTGRES_PASSWORD: postgres
POSTGRES_DB: openproject
networks:
- backend
@ -54,29 +43,79 @@ services:
- backend
backend:
<<: *app
command: "/home/dev/bin/backend"
build:
<<: *build
target: develop
<<: *image
<<: *restart_policy
command: run-app
ports:
- "3000:3000"
environment:
RAILS_ENV: development
RAILS_CACHE_STORE: memcache
OPENPROJECT_CACHE__MEMCACHE__SERVER: cache:11211
OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
OPENPROJECT_STORAGE_TMP__PATH: /tmp/op
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
networks:
- backend
depends_on:
- seeder
frontend:
<<: *app
command: "/home/dev/bin/frontend"
build:
context: .
dockerfile: ./frontend/Dockerfile
args:
DEV_UID: $DEV_UID
DEV_GID: $DEV_GID
command: "npm run serve"
volumes:
- "${OPENPROJECT_HOME:?Please set OPENPROJECT_HOME to the OpenProject root folder}:/home/dev/openproject"
ports:
- "4200:4200"
environment:
PROXY_HOSTNAME: backend
networks:
- frontend
- backend
depends_on:
- seeder
- backend
# The containers below are for testing
db-test:
image: postgres:9
stop_grace_period: "3s"
volumes:
- "pgdata-test:/var/lib/postgresql/data"
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: openproject
networks:
- test
seeder:
<<: *app
command: "/home/dev/bin/seeder"
restart: on-failure
backend-test:
build:
<<: *build
target: test
<<: *image
<<: *restart_policy
command: run-app
networks:
- backend
- test
environment:
RAILS_ENV: test
OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
DATABASE_URL: postgresql://postgres:postgres@db-test/openproject
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: "true"
OPENPROJECT_STORAGE_TMP__PATH: /tmp/op
volumes:
- "${OPENPROJECT_HOME:?Please set OPENPROJECT_HOME to the OpenProject root folder}:/home/dev/openproject"
- "opdata:/var/openproject/assets"
- "bundle:/usr/local/bundle"

@ -0,0 +1,20 @@
FROM node:10.15
MAINTAINER operations@openproject.com
ARG DEV_UID=1000
ARG DEV_GID=1001
ENV USER=dev
RUN usermod -l $USER -d /home/$USER -m node
RUN usermod -u $DEV_UID $USER
RUN groupadd $USER
RUN groupmod -g $DEV_GID $USER
EXPOSE 4200
VOLUME ["/home/$USER/openproject"]
WORKDIR /home/$USER/openproject/frontend
USER $USER

@ -1,16 +0,0 @@
#!/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

@ -1,19 +0,0 @@
#!/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

@ -1,6 +0,0 @@
#!/bin/sh
bundle install \
&& bundle exec rake db:create db:migrate \
&& bundle exec rake db:seed \
&& echo done > tmp/.seeding_status

@ -135,7 +135,7 @@
"prebuild": "./scripts/link_plugin_placeholder.js",
"build": "node --max_old_space_size=2048 ./node_modules/@angular/cli/bin/ng build --prod --named-chunks --extract-css --source-map",
"preserve": "./scripts/link_plugin_placeholder.js",
"serve": "node --max_old_space_size=8096 ./node_modules/@angular/cli/bin/ng serve --public-host http://localhost:4200",
"serve": "node --max_old_space_size=8096 ./node_modules/@angular/cli/bin/ng serve --host 0.0.0.0 --public-host http://localhost:4200",
"pretest": "./scripts/link_plugin_placeholder.js",
"test": "ng test --watch=false",
"tslint_typechecks": "./node_modules/.bin/tslint -p . -c tslint_typechecks.json",

@ -5,7 +5,7 @@ const path = require('path');
const linked_module_example_path = path.join(__dirname, '..', 'src', 'app', 'modules', 'plugins', 'linked-plugins.module.ts.example');
const linked_module_path = path.join(__dirname, '..', 'src', 'app', 'modules', 'plugins', 'linked-plugins.module.ts');
var exists = fs.existsSync(linked_module_path);
const exists = fs.existsSync(linked_module_path);
if (!exists) {
console.log(
@ -13,8 +13,8 @@ if (!exists) {
`If you have active OpenProject plugins, run "rake openproject:plugins:register_frontend" to generate the file with the correct plugins being linked.`
);
var rd = fs.createReadStream(linked_module_example_path);
var wr = fs.createWriteStream(linked_module_path);
const rd = fs.createReadStream(linked_module_example_path);
const wr = fs.createWriteStream(linked_module_path);
return new Promise(function(resolve, reject) {
rd.on('error', reject);

Loading…
Cancel
Save