From 4847c6c9dd67df2acf3de5d24042d3826fe0d36b Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 6 Mar 2022 20:47:30 -0600 Subject: [PATCH] docker: add foreman to base image. Add `foreman` to the base Docker image. This way you can do this: docker run --rm -it -v $PWD:/danbooru ghcr.io/danbooru/danbooru foreman start to start everything needed to run Danbooru in development mode (except for the Postgres database). This will start everything listed in the Procfile: bin/rails server bin/good_job start bin/rails danbooru:cron bin/webpack-dev-server --- Procfile | 15 +++++++++++++-- config/docker/Dockerfile.danbooru | 3 ++- config/docker/build-base-image.sh | 5 +++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Procfile b/Procfile index 28ec3d887..f331fe9f1 100644 --- a/Procfile +++ b/Procfile @@ -7,8 +7,19 @@ # http://blog.daviddollar.org/2011/05/06/introducing-foreman.html # https://github.com/ddollar/foreman -web: bin/rails server +# The main webserver. See config/puma.rb and https://github.com/puma/puma. +# unset PORT to workaround a Puma+Foreman issue (https://github.com/puma/puma/issues/1771) +web: unset PORT && bin/rails server + +# The background job worker. See app/jobs/ and https://github.com/bensheldon/good_job. worker: bin/good_job start + +# The cron job worker. See config/initializers/clockwork.rb and https://github.com/Rykian/clockwork. clock: bin/rails danbooru:cron + +# The Javascript bundler. Rebuilds Javascript/CSS files when they change. See +# config/webpacker.yml and https://webpack.js.org/configuration/dev-server. webpack-dev-server: bin/webpack-dev-server -# db: docker run --rm -it --name danbooru-postgres --shm-size=8g -p 5432:5432 -e POSTGRES_USER=danbooru - e POSTRES_HOST_AUTH_METHOD=trust -v danbooru-postgres:/var/lib/postgresql/data ghcr.io/danbooru/postgres:14.0 + +# The postgres database. It can be run in the Procfile, but it's better to run it manually. +# db: docker run --rm -it --name danbooru-postgres --shm-size=8g -p 5432:5432 -e POSTGRES_USER=danbooru - e POSTRES_HOST_AUTH_METHOD=trust -v danbooru-postgres:/var/lib/postgresql/data ghcr.io/danbooru/postgres:14.1 diff --git a/config/docker/Dockerfile.danbooru b/config/docker/Dockerfile.danbooru index 9e203e696..5ee386e08 100644 --- a/config/docker/Dockerfile.danbooru +++ b/config/docker/Dockerfile.danbooru @@ -27,7 +27,8 @@ RUN \ asdf plugin add nodejs && \ asdf install nodejs "$NODE_VERSION" && \ asdf global nodejs "$NODE_VERSION" && \ - npm install --unsafe-perm=true -g yarn + npm install --unsafe-perm=true -g yarn && \ + chmod -R go+rx /root/.config # make Yarn config dir readable for non-root COPY Gemfile Gemfile.lock ./ RUN \ diff --git a/config/docker/build-base-image.sh b/config/docker/build-base-image.sh index e3dba7600..f300b169b 100755 --- a/config/docker/build-base-image.sh +++ b/config/docker/build-base-image.sh @@ -139,6 +139,10 @@ install_postgresql_client() { apt_install postgresql-client-${POSTGRESQL_CLIENT_VERSION} } +install_foreman() { + gem install foreman +} + install_busybox() { busybox --install -s } @@ -172,5 +176,6 @@ install_vips install_ruby install_openresty install_postgresql_client +install_foreman cleanup install_busybox # after cleanup so we can install some utils removed by cleanup