mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Unified docker image for BIM edition. Add pre/post hooks for other platforms. (#8553)
Unified docker image for BIM edition. Add pre/post hooks for other platforms.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
.github/
|
||||
.git
|
||||
.dockerignore
|
||||
.bundle
|
||||
@@ -22,5 +23,6 @@ spec
|
||||
spec_legacy
|
||||
tmp
|
||||
frontend/node_modules
|
||||
node_modules
|
||||
# travis
|
||||
vendor/bundle
|
||||
|
||||
@@ -14,11 +14,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Publish to registry
|
||||
- name: Build & Push
|
||||
id: build_and_push
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
with:
|
||||
name: openproject/community-test
|
||||
name: openproject/community
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
tag_semver: true
|
||||
cache: ${{ github.event_name != 'schedule' }}
|
||||
- name: Test
|
||||
run: |
|
||||
docker run -d -p 8080:80 -e SUPERVISORD_LOG_LEVEL=debug -e SECRET_KEY_BASE=secret ${{ steps.build_and_push.outputs.digest }}
|
||||
curl --fail -ks --retry 10 http://localhost:8080/api/v3
|
||||
|
||||
+37
-62
@@ -6,83 +6,58 @@ RUN /tmp/build-pgloader && rm /tmp/build-pgloader
|
||||
FROM ruby:2.6-stretch
|
||||
MAINTAINER operations@openproject.com
|
||||
|
||||
ENV NODE_VERSION "10.15.0"
|
||||
ENV BUNDLER_VERSION "2.0.2"
|
||||
ENV BUNDLE_PATH__SYSTEM=false
|
||||
ENV APP_USER app
|
||||
ENV APP_PATH /app
|
||||
ENV APP_DATA_PATH /var/openproject/assets
|
||||
ENV APP_DATA_PATH_LEGACY /var/db/openproject
|
||||
ENV PGDATA /var/openproject/pgdata
|
||||
ENV PGDATA_LEGACY /var/lib/postgresql/9.6/main
|
||||
# Allow platform-specific additions. Valid values are: on-prem,saas,bahn
|
||||
ARG PLATFORM=on-prem
|
||||
# Use OAuth token in case private gems need to be fetched
|
||||
ARG GITHUB_OAUTH_TOKEN
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
ENV DATABASE_URL postgres://openproject:openproject@127.0.0.1/openproject
|
||||
ENV RAILS_ENV production
|
||||
ENV HEROKU true
|
||||
ENV RAILS_CACHE_STORE memcache
|
||||
ENV OPENPROJECT_INSTALLATION__TYPE docker
|
||||
ENV NEW_RELIC_AGENT_ENABLED false
|
||||
ENV ATTACHMENTS_STORAGE_PATH $APP_DATA_PATH/files
|
||||
ENV NODE_VERSION="12.18.3"
|
||||
ENV BUNDLER_VERSION="2.0.2"
|
||||
ENV BUNDLE_PATH__SYSTEM=false
|
||||
ENV APP_USER=app
|
||||
ENV APP_PATH=/app
|
||||
ENV APP_DATA_PATH=/var/openproject/assets
|
||||
ENV APP_DATA_PATH_LEGACY=/var/db/openproject
|
||||
ENV PGBIN="/usr/lib/postgresql/9.6/bin"
|
||||
ENV PGDATA=/var/openproject/pgdata
|
||||
ENV PGDATA_LEGACY=/var/lib/postgresql/9.6/main
|
||||
|
||||
ENV DATABASE_URL=postgres://openproject:openproject@127.0.0.1/openproject
|
||||
ENV HEROKU=true
|
||||
ENV RAILS_ENV=production
|
||||
ENV RAILS_CACHE_STORE=memcache
|
||||
ENV RAILS_GROUPS="production docker opf_plugins"
|
||||
ENV OPENPROJECT_INSTALLATION__TYPE=docker
|
||||
# Valid values are: standard,bim
|
||||
ENV OPENPROJECT_EDITION=standard
|
||||
ENV NEW_RELIC_AGENT_ENABLED=false
|
||||
ENV ATTACHMENTS_STORAGE_PATH=$APP_DATA_PATH/files
|
||||
# Set a default key base, ensure to provide a secure value in production environments!
|
||||
ENV SECRET_KEY_BASE OVERWRITE_ME
|
||||
ENV SECRET_KEY_BASE=OVERWRITE_ME
|
||||
|
||||
COPY --from=pgloader /usr/local/bin/pgloader-ccl /usr/local/bin/
|
||||
|
||||
# install node + npm
|
||||
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 apt-get update -qq && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
postgresql-client \
|
||||
poppler-utils \
|
||||
unrtf \
|
||||
tesseract-ocr \
|
||||
catdoc \
|
||||
memcached \
|
||||
postfix \
|
||||
postgresql \
|
||||
apache2 \
|
||||
supervisor && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set up pg defaults
|
||||
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
|
||||
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.6/main/postgresql.conf
|
||||
RUN echo "data_directory='$PGDATA'" >> /etc/postgresql/9.6/main/postgresql.conf
|
||||
RUN rm -rf "$PGDATA_LEGACY" && rm -rf "$PGDATA" && mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA"
|
||||
RUN a2enmod proxy proxy_http && rm -f /etc/apache2/sites-enabled/000-default.conf
|
||||
|
||||
# using /home/app since npm cache and other stuff will be put there when running npm install
|
||||
# we don't want to pollute any locally-mounted directory
|
||||
RUN useradd -d /home/$APP_USER -m $APP_USER
|
||||
|
||||
WORKDIR $APP_PATH
|
||||
RUN gem install bundler --version "${bundler_version}" --no-document
|
||||
|
||||
COPY docker/setup ./docker/setup
|
||||
RUN ./docker/setup/preinstall.sh
|
||||
|
||||
COPY Gemfile ./Gemfile
|
||||
COPY Gemfile.* ./
|
||||
COPY modules ./modules
|
||||
# OpenProject::Version is required by module versions in gemspecs
|
||||
RUN mkdir -p lib/open_project
|
||||
COPY lib/open_project/version.rb ./lib/open_project/
|
||||
RUN bundle install --deployment --path vendor/bundle --no-cache \
|
||||
--with="docker opf_plugins" --without="test development" --jobs=8 --retry=3 && \
|
||||
COPY vendor ./vendor
|
||||
# some gemspec files of plugins require files in there, notably OpenProject::Version
|
||||
COPY lib ./lib
|
||||
|
||||
RUN bundle install --quiet --deployment --path vendor/bundle --no-cache \
|
||||
--with="$RAILS_GROUPS" --without="test development" --jobs=8 --retry=3 && \
|
||||
rm -rf vendor/bundle/ruby/*/cache && rm -rf vendor/bundle/ruby/*/gems/*/spec && rm -rf vendor/bundle/ruby/*/gems/*/test
|
||||
|
||||
# Finally, copy over the whole thing
|
||||
COPY . .
|
||||
|
||||
# Re-use packager database.yml
|
||||
RUN cp ./packaging/conf/database.yml ./config/database.yml
|
||||
# Add MySQL-to-Postgres migration script to path (used in entrypoint.sh)
|
||||
RUN cp ./docker/mysql-to-postgres/bin/migrate-mysql-to-postgres /usr/local/bin/
|
||||
# Ensure OpenProject starts with the docker group of gems
|
||||
RUN sed -i "s|Rails.groups(:opf_plugins)|Rails.groups(:opf_plugins, :docker)|" config/application.rb
|
||||
# Ensure we can write in /tmp/op_uploaded_files (cf. #29112)
|
||||
RUN mkdir -p /tmp/op_uploaded_files/ && chown -R $APP_USER:$APP_USER /tmp/op_uploaded_files/
|
||||
|
||||
# Handle the assets precompilation
|
||||
RUN bash docker/precompile-assets.sh
|
||||
RUN ./docker/setup/postinstall.sh
|
||||
|
||||
# Expose ports for apache and postgres
|
||||
EXPOSE 80 5432
|
||||
|
||||
@@ -67,11 +67,18 @@ if [ "$(id -u)" = '0' ]; then
|
||||
mkdir -p "$APP_PATH/log" "$APP_PATH/tmp/pids" "$APP_PATH/files"
|
||||
chown "$APP_USER:$APP_USER" "$APP_PATH"
|
||||
chown -R "$APP_USER:$APP_USER" "$APP_PATH/log" "$APP_PATH/tmp" "$APP_PATH/files" "$APP_PATH/public"
|
||||
|
||||
# allow to launch any command as root by prepending it with 'root'
|
||||
if [ "$1" = "root" ]; then
|
||||
shift
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
if [ "$1" = "./docker/supervisord" ] || [ "$1" = "./docker/proxy" ]; then
|
||||
exec "$@"
|
||||
else
|
||||
exec $APP_PATH/docker/gosu $APP_USER "$BASH_SOURCE" "$@"
|
||||
fi
|
||||
|
||||
exec $APP_PATH/docker/gosu $APP_USER "$BASH_SOURCE" "$@"
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
pushd "${APP_PATH}/frontend"
|
||||
|
||||
export NG_CLI_ANALYTICS=ci # so angular cli doesn't block waiting for user input
|
||||
|
||||
# Installing frontend dependencies
|
||||
RAILS_ENV=production npm install
|
||||
|
||||
popd
|
||||
|
||||
# Bundle assets
|
||||
DATABASE_URL='nulldb://nohost' RAILS_ENV=production bundle exec rake assets:precompile
|
||||
|
||||
# Remove sprockets cache
|
||||
rm -rf "$APP_PATH/tmp/cache/assets"
|
||||
|
||||
# Remove node_modules and entire frontend
|
||||
rm -rf "$APP_PATH/node_modules/" "$APP_PATH/frontend/node_modules/"
|
||||
|
||||
# Clean cache in root
|
||||
rm -rf /root/.npm
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
display_error() {
|
||||
echo " !--> ERROR on postinstall:"
|
||||
tail -n 200 /tmp/dockerize.log
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo " ---> POSTINSTALL"
|
||||
|
||||
# Add MySQL-to-Postgres migration script to path (used in entrypoint.sh)
|
||||
cp ./docker/mysql-to-postgres/bin/migrate-mysql-to-postgres /usr/local/bin/
|
||||
|
||||
# Ensure we can write in /tmp/op_uploaded_files (cf. #29112)
|
||||
mkdir -p /tmp/op_uploaded_files/ && chown -R $APP_USER:$APP_USER /tmp/op_uploaded_files/
|
||||
|
||||
rm -f ./config/database.yml
|
||||
|
||||
if test -f ./docker/setup/postinstall-$PLATFORM.sh ; then
|
||||
echo " ---> Executing postinstall for $PLATFORM..."
|
||||
./docker/setup/postinstall-$PLATFORM.sh
|
||||
fi
|
||||
|
||||
echo " ---> Precompiling assets. This will take a while..."
|
||||
|
||||
(
|
||||
pushd "${APP_PATH}/frontend"
|
||||
|
||||
export NG_CLI_ANALYTICS=ci # so angular cli doesn't block waiting for user input
|
||||
|
||||
# Installing frontend dependencies
|
||||
RAILS_ENV=production npm install
|
||||
|
||||
popd
|
||||
|
||||
# Bundle assets
|
||||
su - postgres -c "$PGBIN/initdb -D /tmp/nulldb"
|
||||
su - postgres -c "$PGBIN/pg_ctl -D /tmp/nulldb -l /dev/null -w start"
|
||||
echo "create database assets; create user assets with encrypted password 'p4ssw0rd'; grant all privileges on database assets to assets;" | su - postgres -c psql
|
||||
DATABASE_URL=postgres://assets:p4ssw0rd@127.0.0.1/assets RAILS_ENV=production bundle exec rake db:migrate db:schema:dump db:schema:cache:dump assets:precompile
|
||||
|
||||
su - postgres -c "$PGBIN/pg_ctl -D /tmp/nulldb stop"
|
||||
|
||||
rm -rf /tmp/nulldb
|
||||
|
||||
# Remove sprockets cache
|
||||
rm -rf "$APP_PATH/tmp/cache/assets"
|
||||
|
||||
# Remove node_modules and entire frontend
|
||||
rm -rf "$APP_PATH/node_modules/" "$APP_PATH/frontend/node_modules/"
|
||||
|
||||
# Clean cache in root
|
||||
rm -rf /root/.npm
|
||||
) >/tmp/dockerize.log || display_error
|
||||
|
||||
rm -f /tmp/dockerize.log
|
||||
echo " OK."
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
apt-get install -y \
|
||||
memcached \
|
||||
postfix \
|
||||
apache2 \
|
||||
supervisor
|
||||
|
||||
a2enmod proxy proxy_http
|
||||
rm -f /etc/apache2/sites-enabled/000-default.conf
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo " ---> PREINSTALL"
|
||||
|
||||
display_error() {
|
||||
echo " !--> ERROR on preinstall:"
|
||||
tail -n 200 /tmp/dockerize.log
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo " ---> Setting up common dependencies. This will take a while..."
|
||||
apt-get update -qq
|
||||
|
||||
(
|
||||
# install node + npm
|
||||
curl -s https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz | \
|
||||
tar xzf - -C /usr/local --strip-components=1
|
||||
|
||||
apt-get install -y \
|
||||
apt-transport-https \
|
||||
postgresql-client \
|
||||
pandoc \
|
||||
poppler-utils \
|
||||
unrtf \
|
||||
tesseract-ocr \
|
||||
catdoc \
|
||||
postgresql
|
||||
|
||||
# Set up pg defaults
|
||||
echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
|
||||
echo "listen_addresses='*'" >> /etc/postgresql/9.6/main/postgresql.conf
|
||||
echo "data_directory='$PGDATA'" >> /etc/postgresql/9.6/main/postgresql.conf
|
||||
rm -rf "$PGDATA_LEGACY" && rm -rf "$PGDATA" && mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA"
|
||||
|
||||
# Specifics for BIM edition
|
||||
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
|
||||
wget -q https://packages.microsoft.com/config/debian/9/prod.list -O /etc/apt/sources.list.d/microsoft-prod.list
|
||||
apt-get update -qq
|
||||
apt-get install -y dotnet-runtime-3.1
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
cd $tmpdir
|
||||
|
||||
# Install XKT converter
|
||||
npm install xeokit/xeokit-gltf-to-xkt -g
|
||||
|
||||
# Install COLLADA2GLTF
|
||||
wget --quiet https://github.com/KhronosGroup/COLLADA2GLTF/releases/download/v2.1.5/COLLADA2GLTF-v2.1.5-linux.zip
|
||||
unzip -q COLLADA2GLTF-v2.1.5-linux.zip
|
||||
mv COLLADA2GLTF-bin "/usr/local/bin/COLLADA2GLTF"
|
||||
|
||||
# IFCconvert
|
||||
wget --quiet https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v0.6.0-9bcd932-linux64.zip
|
||||
unzip -q IfcConvert-v0.6.0-9bcd932-linux64.zip
|
||||
mv IfcConvert "/usr/local/bin/IfcConvert"
|
||||
|
||||
wget --quiet https://github.com/bimspot/xeokit-metadata/releases/download/1.0.0/xeokit-metadata-linux-x64.tar.gz
|
||||
tar -zxvf xeokit-metadata-linux-x64.tar.gz
|
||||
chmod +x xeokit-metadata-linux-x64/xeokit-metadata
|
||||
cp -r xeokit-metadata-linux-x64/ "/usr/lib/xeokit-metadata"
|
||||
ln -s /usr/lib/xeokit-metadata/xeokit-metadata /usr/local/bin/xeokit-metadata
|
||||
|
||||
cd /
|
||||
rm -rf $tmpdir
|
||||
|
||||
gem install bundler --version "$BUNDLER_VERSION" --no-document
|
||||
|
||||
useradd -d /home/$APP_USER -m $APP_USER
|
||||
|
||||
) >/tmp/dockerize.log || display_error
|
||||
|
||||
if test -f ./docker/setup/preinstall-$PLATFORM.sh ; then
|
||||
echo " ---> Executing preinstall for $PLATFORM..."
|
||||
./docker/setup/preinstall-$PLATFORM.sh >/tmp/dockerize.log || display_error
|
||||
fi
|
||||
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
rm -f /tmp/dockerize.log
|
||||
echo " OK."
|
||||
@@ -18,7 +18,6 @@ PGUSER=${PGUSER:=postgres}
|
||||
PGPASSWORD=${PGPASSWORD:=postgres}
|
||||
PG_STARTUP_WAIT_TIME=${PG_STARTUP_WAIT_TIME:=10}
|
||||
SUPERVISORD_LOG_LEVEL=${SUPERVISORD_LOG_LEVEL:=info}
|
||||
PGBIN="/usr/lib/postgresql/9.6/bin"
|
||||
|
||||
dbhost=$(ruby -ruri -e 'puts URI(ENV.fetch("DATABASE_URL")).host')
|
||||
pwfile=$(mktemp)
|
||||
|
||||
Reference in New Issue
Block a user