From fe7f480014242436bab067036340bc64c798b0d4 Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Wed, 19 Mar 2025 11:19:32 -0400 Subject: [PATCH 1/8] Rebuild entrypoint to be run all `.sh` files in docker-entrypoint.d/ --- Dockerfile | 11 +++--- docker-entrypoint.d/10-remove-pid.sh | 6 +++ .../20-database-url.sh | 7 +--- docker-entrypoint.d/30-bundle-install.sh | 13 +++++++ docker-entrypoint.d/40-node-install.sh | 16 ++++++++ docker-entrypoint.sh | 30 +++++++++++++++ local.Dockerfile | 11 +++--- local.entrypoint.sh | 38 ------------------- webapp/Dockerfile | 11 +++--- webapp/local.Dockerfile | 11 +++--- 10 files changed, 90 insertions(+), 64 deletions(-) create mode 100644 docker-entrypoint.d/10-remove-pid.sh rename entrypoint.sh => docker-entrypoint.d/20-database-url.sh (80%) create mode 100644 docker-entrypoint.d/30-bundle-install.sh create mode 100644 docker-entrypoint.d/40-node-install.sh create mode 100644 docker-entrypoint.sh delete mode 100644 local.entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 5496455..93975b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,3 @@ -# syntax=docker/dockerfile:1 - ARG RUBY_VERSION=3.3 FROM ruby:${RUBY_VERSION}-alpine @@ -11,9 +9,12 @@ RUN apk add --no-cache --update \ # Set up entrypoint WORKDIR / -COPY entrypoint.sh . -RUN chmod +x entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] +COPY docker-entrypoint.sh . +RUN chmod +x /docker-entrypoint.sh +ENTRYPOINT ["/docker-entrypoint.sh"] +WORKDIR /docker-entrypoint.d +COPY docker-entrypoint.d/*.sh . +RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundle path RUN mkdir -p /usr/local/bundle diff --git a/docker-entrypoint.d/10-remove-pid.sh b/docker-entrypoint.d/10-remove-pid.sh new file mode 100644 index 0000000..d94bbfa --- /dev/null +++ b/docker-entrypoint.d/10-remove-pid.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -ex + +echo "Removing pid file" +rm -f "${PIDFILE}" diff --git a/entrypoint.sh b/docker-entrypoint.d/20-database-url.sh similarity index 80% rename from entrypoint.sh rename to docker-entrypoint.d/20-database-url.sh index 6b4b006..ddaaa88 100644 --- a/entrypoint.sh +++ b/docker-entrypoint.d/20-database-url.sh @@ -1,9 +1,6 @@ #!/bin/sh -set -e - -# Remove puma.pid so that a docker restart doesn't prevent puma from starting -rm -f /var/run/puma.pid +set -ex # Configure DATABASE_URL if POSTGRES_URL is set if [ -n "${POSTGRES_URL}" ]; then @@ -20,5 +17,3 @@ if [ -n "${MYSQL_URL}" ]; then echo "Configuring DATABASE_URL using MYSQL_URL" export DATABASE_URL="${MYSQL_URL}" fi - -exec "$@" diff --git a/docker-entrypoint.d/30-bundle-install.sh b/docker-entrypoint.d/30-bundle-install.sh new file mode 100644 index 0000000..c416296 --- /dev/null +++ b/docker-entrypoint.d/30-bundle-install.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -ex + +if [ "${NULLSTONE_ENV}" = "local" ]; then + echo "Installing bundler..." + gem install bundler + + echo "Verifying and installing gems..." + bundle check || bundle install +else + echo "Skipping bundle install (not a local environment)" +fi diff --git a/docker-entrypoint.d/40-node-install.sh b/docker-entrypoint.d/40-node-install.sh new file mode 100644 index 0000000..f7d5090 --- /dev/null +++ b/docker-entrypoint.d/40-node-install.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -ex + +if [ "${NULLSTONE_ENV}" = "local" ]; then + if [ -f "yarn.lock" ]; then + echo "Installing yarn dependencies..." + yarn install + fi + if [ -f "package-lock.json" ]; then + echo "Installing npm dependencies..." + npm install + fi +else + echo "Skipping node install (not a local environment)" +fi \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..265f13e --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +set -e + +if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then + echo >&2 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration" + + echo >&2 "$0: Looking for shell scripts in /docker-entrypoint.d/" + find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do + case "$f" in + *.sh) + if [ -x "$f" ]; then + echo >&2 "$0: Launching $f"; + # shellcheck source=/docker-entrypoint.d/{script.sh} + . "$f" + else + # warn on shell scripts without exec bit + echo >&2 "$0: Ignoring $f, not executable"; + fi + ;; + *) echo >&2 "$0: Ignoring $f";; + esac + done + + echo >&2 "$0: Configuration complete; ready for start up" +else + echo >&2 "$0: No files found in /docker-entrypoint.d/, skipping configuration" +fi + +exec "$@" diff --git a/local.Dockerfile b/local.Dockerfile index 7d78dc6..03edb36 100644 --- a/local.Dockerfile +++ b/local.Dockerfile @@ -1,5 +1,3 @@ -# syntax=docker/dockerfile:1 - ARG RUBY_VERSION=3.3 FROM ruby:${RUBY_VERSION}-alpine @@ -11,9 +9,12 @@ RUN apk add --no-cache --update \ # Set up entrypoint WORKDIR / -COPY local.entrypoint.sh . -RUN chmod +x local.entrypoint.sh -ENTRYPOINT ["/local.entrypoint.sh"] +COPY docker-entrypoint.sh . +RUN chmod +x /docker-entrypoint.sh +ENTRYPOINT ["/docker-entrypoint.sh"] +WORKDIR /docker-entrypoint.d +COPY docker-entrypoint.d/*.sh . +RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundle path RUN mkdir -p /usr/local/bundle diff --git a/local.entrypoint.sh b/local.entrypoint.sh deleted file mode 100644 index 587554f..0000000 --- a/local.entrypoint.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -set -e - -echo "Installing bundler..." -gem install bundler -echo "Verifying and installing gems..." -bundle check || bundle install - -if [ -f "yarn.lock" ]; then - echo "Installing yarn dependencies..." - yarn install -fi -if [ -f "package-lock.json" ]; then - echo "Installing npm dependencies..." - npm install -fi - -# Remove puma.pid so that a docker restart doesn't prevent puma from starting -rm -f /var/run/puma.pid - -# Configure DATABASE_URL if POSTGRES_URL is set -if [ -n "${POSTGRES_URL}" ]; then - echo "Setting DB_ADAPTER=postgresql" - export DB_ADAPTER=postgresql - echo "Configuring DATABASE_URL using POSTGRES_URL" - export DATABASE_URL="${POSTGRES_URL}" -fi - -# Configure DATABASE_URL if MYSQL_URL is set -if [ -n "${MYSQL_URL}" ]; then - echo "Setting DB_ADAPTER=mysql2" - export DB_ADAPTER=mysql2 - echo "Configuring DATABASE_URL using MYSQL_URL" - export DATABASE_URL="${MYSQL_URL}" -fi - -exec "$@" diff --git a/webapp/Dockerfile b/webapp/Dockerfile index c50335f..b049dad 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -1,5 +1,3 @@ -# syntax=docker/dockerfile:1 - ARG RUBY_VERSION=3.3 FROM ruby:${RUBY_VERSION}-alpine @@ -18,9 +16,12 @@ COPY etc/ /etc/ # Set up entrypoint WORKDIR / -COPY entrypoint.sh . -RUN chmod +x entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] +COPY docker-entrypoint.sh . +RUN chmod +x /docker-entrypoint.sh +ENTRYPOINT ["/docker-entrypoint.sh"] +WORKDIR /docker-entrypoint.d +COPY docker-entrypoint.d/*.sh . +RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundle path RUN mkdir -p /usr/local/bundle diff --git a/webapp/local.Dockerfile b/webapp/local.Dockerfile index d3f5fd7..d225c36 100644 --- a/webapp/local.Dockerfile +++ b/webapp/local.Dockerfile @@ -1,5 +1,3 @@ -# syntax=docker/dockerfile:1 - ARG RUBY_VERSION=3.3 FROM ruby:${RUBY_VERSION}-alpine @@ -18,9 +16,12 @@ COPY etc/ /etc/ # Set up entrypoint WORKDIR / -COPY local.entrypoint.sh . -RUN chmod +x local.entrypoint.sh -ENTRYPOINT ["/local.entrypoint.sh"] +COPY docker-entrypoint.sh . +RUN chmod +x /docker-entrypoint.sh +ENTRYPOINT ["/docker-entrypoint.sh"] +WORKDIR /docker-entrypoint.d +COPY docker-entrypoint.d/*.sh . +RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundle path RUN mkdir -p /usr/local/bundle From 1fcdf1a34be3b2e69d2644f9333df38008ba7d36 Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Wed, 19 Mar 2025 12:00:44 -0400 Subject: [PATCH 2/8] Remove support for "local" image variants --- Dockerfile | 1 - README.md | 10 ---- docker-bake.hcl | 118 ---------------------------------------- local.Dockerfile | 36 ------------ webapp/Dockerfile | 1 - webapp/local.Dockerfile | 43 --------------- 6 files changed, 209 deletions(-) delete mode 100644 local.Dockerfile delete mode 100644 webapp/local.Dockerfile diff --git a/Dockerfile b/Dockerfile index 93975b2..2bc6896 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,6 @@ ENV PIDFILE /var/run/puma.pid # Configure default environment setup WORKDIR /app -ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV BINDING 0.0.0.0 diff --git a/README.md b/README.md index e74080c..e7f74b9 100644 --- a/README.md +++ b/README.md @@ -14,33 +14,23 @@ This image is very opinionated; however, not restrictive. ### Ruby 3.3 - [ruby3.3, ruby3, latest](Dockerfile) -- [ruby3.3-local, ruby3-local, local](local.Dockerfile) - [ruby3.3-webapp, ruby3-webapp, webapp](webapp/Dockerfile) -- [ruby3.3-webapp-local, ruby3-webapp-local, webapp-local](webapp/local.Dockerfile) ### Ruby 3.2 - [ruby3.2](Dockerfile) -- [ruby3.2-local](local.Dockerfile) - [ruby3.2-webapp](webapp/Dockerfile) -- [ruby3.2-webapp-local](webapp/local.Dockerfile) - ### Ruby 3.1 - [ruby3.1](Dockerfile) -- [ruby3.1-local](local.Dockerfile) - [ruby3.1-webapp](webapp/Dockerfile) -- [ruby3.1-webapp-local](webapp/local.Dockerfile) ### Ruby 3.0 - [ruby3.0](Dockerfile) -- [ruby3.0-local](local.Dockerfile) - [ruby3.0-webapp](webapp/Dockerfile) -- [ruby3.0-webapp-local](webapp/local.Dockerfile) ### Ruby 2.7 - [ruby2.7](Dockerfile) -- [ruby2.7-local](local.Dockerfile) - [ruby2.7-webapp](webapp/Dockerfile) -- [ruby2.7-webapp-local](webapp/local.Dockerfile) ## Production vs Local diff --git a/docker-bake.hcl b/docker-bake.hcl index 1ace1fe..b87711d 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,29 +1,19 @@ group "default" { targets = [ "ruby3-3", - "ruby3-3-local", "ruby3-3-webapp", - "ruby3-3-webapp-local", "ruby3-2", - "ruby3-2-local", "ruby3-2-webapp", - "ruby3-2-webapp-local", "ruby3-1", - "ruby3-1-local", "ruby3-1-webapp", - "ruby3-1-webapp-local", "ruby3-0", - "ruby3-0-local", "ruby3-0-webapp", - "ruby3-0-webapp-local", "ruby2-7", - "ruby2-7-local", "ruby2-7-webapp", - "ruby2-7-webapp-local", ] } @@ -39,18 +29,6 @@ target "ruby3-3" { } } -target "ruby3-3-local" { - dockerfile = "local.Dockerfile" - tags = [ - "nullstone/rails:ruby3.3-local", - "nullstone/rails:ruby3-local", - "nullstone/rails:local", - ] - args = { - "RUBY_VERSION" = "3.3" - } -} - target "ruby3-3-webapp" { dockerfile = "webapp/Dockerfile" tags = [ @@ -63,24 +41,10 @@ target "ruby3-3-webapp" { } } -target "ruby3-3-webapp-local" { - dockerfile = "webapp/local.Dockerfile" - tags = [ - "nullstone/rails:ruby3.3-webapp-local", - "nullstone/rails:ruby3-webapp-local", - "nullstone/rails:webapp-local" - ] - args = { - "RUBY_VERSION" = "3.3" - } -} - group "group-ruby3-2" { targets = [ "ruby3-2", - "ruby3-2-local", "ruby3-2-webapp", - "ruby3-2-webapp-local", ] } @@ -92,14 +56,6 @@ target "ruby3-2" { } } -target "ruby3-2-local" { - dockerfile = "local.Dockerfile" - tags = ["nullstone/rails:ruby3.2-local"] - args = { - "RUBY_VERSION" = "3.2.2" - } -} - target "ruby3-2-webapp" { dockerfile = "webapp/Dockerfile" tags = ["nullstone/rails:ruby3.2-webapp"] @@ -108,20 +64,10 @@ target "ruby3-2-webapp" { } } -target "ruby3-2-webapp-local" { - dockerfile = "webapp/local.Dockerfile" - tags = ["nullstone/rails:ruby3.2-webapp-local"] - args = { - "RUBY_VERSION" = "3.2.2" - } -} - group "group-ruby3-1" { targets = [ "ruby3-1", - "ruby3-1-local", "ruby3-1-webapp", - "ruby3-1-webapp-local", ] } @@ -135,16 +81,6 @@ target "ruby3-1" { } } -target "ruby3-1-local" { - dockerfile = "local.Dockerfile" - tags = [ - "nullstone/rails:ruby3.1-local", - ] - args = { - "RUBY_VERSION" = "3.1" - } -} - target "ruby3-1-webapp" { dockerfile = "webapp/Dockerfile" tags = [ @@ -155,22 +91,10 @@ target "ruby3-1-webapp" { } } -target "ruby3-1-webapp-local" { - dockerfile = "webapp/local.Dockerfile" - tags = [ - "nullstone/rails:ruby3.1-webapp-local", - ] - args = { - "RUBY_VERSION" = "3.1" - } -} - group "group-ruby3-0" { targets = [ "ruby3-0", - "ruby3-0-local", "ruby3-0-webapp", - "ruby3-0-webapp-local", ] } @@ -184,16 +108,6 @@ target "ruby3-0" { } } -target "ruby3-0-local" { - dockerfile = "local.Dockerfile" - tags = [ - "nullstone/rails:ruby3.0-local" - ] - args = { - "RUBY_VERSION" = "3.0" - } -} - target "ruby3-0-webapp" { dockerfile = "webapp/Dockerfile" tags = [ @@ -204,22 +118,10 @@ target "ruby3-0-webapp" { } } -target "ruby3-0-webapp-local" { - dockerfile = "webapp/local.Dockerfile" - tags = [ - "nullstone/rails:ruby3.0-webapp-local" - ] - args = { - "RUBY_VERSION" = "3.0" - } -} - group "group-ruby2-7" { targets = [ "ruby2-7", - "ruby2-7-local", "ruby2-7-webapp", - "ruby2-7-webapp-local", ] } @@ -233,16 +135,6 @@ target "ruby2-7" { } } -target "ruby2-7-local" { - dockerfile = "local.Dockerfile" - tags = [ - "nullstone/rails:ruby2.7-local" - ] - args = { - "RUBY_VERSION" = "2.7" - } -} - target "ruby2-7-webapp" { dockerfile = "webapp/Dockerfile" tags = [ @@ -252,13 +144,3 @@ target "ruby2-7-webapp" { "RUBY_VERSION" = "2.7" } } - -target "ruby2-7-webapp-local" { - dockerfile = "webapp/local.Dockerfile" - tags = [ - "nullstone/rails:ruby2.7-webapp-local" - ] - args = { - "RUBY_VERSION" = "2.7" - } -} diff --git a/local.Dockerfile b/local.Dockerfile deleted file mode 100644 index 03edb36..0000000 --- a/local.Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -ARG RUBY_VERSION=3.3 -FROM ruby:${RUBY_VERSION}-alpine - -RUN apk add --no-cache --update \ - build-base \ - postgresql-client \ - postgresql-dev \ - tzdata - -# Set up entrypoint -WORKDIR / -COPY docker-entrypoint.sh . -RUN chmod +x /docker-entrypoint.sh -ENTRYPOINT ["/docker-entrypoint.sh"] -WORKDIR /docker-entrypoint.d -COPY docker-entrypoint.d/*.sh . -RUN chmod +x /docker-entrypoint.d/*.sh - -# Set up bundle path -RUN mkdir -p /usr/local/bundle -ENV BUNDLE_PATH /usr/local/bundle - -# Set up pid file -RUN mkdir -p /var/run/ -ENV PIDFILE /var/run/puma.pid - -# Configure default environment setup -WORKDIR /app -ENV RAILS_ENV development -ENV RAILS_LOG_TO_STDOUT true - -ENV BINDING 0.0.0.0 -ENV PORT 80 -EXPOSE 80 - -CMD ["bundle", "exec", "rails", "server"] diff --git a/webapp/Dockerfile b/webapp/Dockerfile index b049dad..78b4131 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -33,7 +33,6 @@ ENV PIDFILE /var/run/puma.pid # Configure default environment setup WORKDIR /app -ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV BINDING 0.0.0.0 diff --git a/webapp/local.Dockerfile b/webapp/local.Dockerfile deleted file mode 100644 index d225c36..0000000 --- a/webapp/local.Dockerfile +++ /dev/null @@ -1,43 +0,0 @@ -ARG RUBY_VERSION=3.3 -FROM ruby:${RUBY_VERSION}-alpine - -RUN apk add --no-cache --update \ - build-base \ - postgresql-client \ - postgresql-dev \ - nodejs yarn \ - tzdata - -VOLUME /etc/nginx/conf.d -VOLUME /etc/nginx/templates -VOLUME /app/public - -COPY etc/ /etc/ - -# Set up entrypoint -WORKDIR / -COPY docker-entrypoint.sh . -RUN chmod +x /docker-entrypoint.sh -ENTRYPOINT ["/docker-entrypoint.sh"] -WORKDIR /docker-entrypoint.d -COPY docker-entrypoint.d/*.sh . -RUN chmod +x /docker-entrypoint.d/*.sh - -# Set up bundle path -RUN mkdir -p /usr/local/bundle -ENV BUNDLE_PATH /usr/local/bundle - -# Set up pid file -RUN mkdir -p /var/run/ -ENV PIDFILE /var/run/puma.pid - -# Configure default environment setup -WORKDIR /app -ENV RAILS_ENV development -ENV RAILS_LOG_TO_STDOUT true - -ENV BINDING 0.0.0.0 -ENV PORT 9000 -EXPOSE 9000 - -CMD ["bundle", "exec", "rails", "server"] From 910fe28f3d3438efe55ab2a6e781f5fb33e79b9f Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Wed, 19 Mar 2025 12:58:30 -0400 Subject: [PATCH 3/8] fix deprecated env syntax --- Dockerfile | 10 +++++----- webapp/Dockerfile | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2bc6896..51d6e6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,18 +18,18 @@ RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundle path RUN mkdir -p /usr/local/bundle -ENV BUNDLE_PATH /usr/local/bundle +ENV BUNDLE_PATH=/usr/local/bundle # Set up pid file RUN mkdir -p /var/run/ -ENV PIDFILE /var/run/puma.pid +ENV PIDFILE=/var/run/puma.pid # Configure default environment setup WORKDIR /app -ENV RAILS_LOG_TO_STDOUT true +ENV RAILS_LOG_TO_STDOUT=true -ENV BINDING 0.0.0.0 -ENV PORT 80 +ENV BINDING=0.0.0.0 +ENV PORT=80 EXPOSE 80 CMD ["bundle", "exec", "rails", "server"] diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 78b4131..63f53b4 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -25,18 +25,18 @@ RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundle path RUN mkdir -p /usr/local/bundle -ENV BUNDLE_PATH /usr/local/bundle +ENV BUNDLE_PATH=/usr/local/bundle # Set up pid file RUN mkdir -p /var/run/ -ENV PIDFILE /var/run/puma.pid +ENV PIDFILE=/var/run/puma.pid # Configure default environment setup WORKDIR /app -ENV RAILS_LOG_TO_STDOUT true +ENV RAILS_LOG_TO_STDOUT=true -ENV BINDING 0.0.0.0 -ENV PORT 9000 +ENV BINDING=0.0.0.0 +ENV PORT=9000 EXPOSE 9000 CMD ["bundle", "exec", "rails", "server"] From 8d2be91c0f09db4028f44dfd886986dcaba7d651 Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Wed, 19 Mar 2025 12:58:59 -0400 Subject: [PATCH 4/8] Now building docker images for ruby patch versions --- Makefile | 13 ++++- docker-bake.hcl | 143 ++++------------------------------------------ ruby_versions.txt | 27 +++++++++ 3 files changed, 48 insertions(+), 135 deletions(-) create mode 100644 ruby_versions.txt diff --git a/Makefile b/Makefile index 996b26c..8acfc43 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,14 @@ +RUBY_VERSIONS_FILE := ruby_versions.txt + +.PHONY: build build: - docker buildx bake + @while IFS= read -r version; do \ + echo "Building for Ruby $$version..."; \ + RUBY_VERSION=$$version docker buildx bake; \ + done < $(RUBY_VERSIONS_FILE) push: - docker buildx bake --push + @while IFS= read -r version; do \ + echo "Building and pushing for Ruby $$version..."; \ + RUBY_VERSION=$$version docker buildx bake --push; \ + done < $(RUBY_VERSIONS_FILE) diff --git a/docker-bake.hcl b/docker-bake.hcl index b87711d..4de5ca4 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,146 +1,23 @@ -group "default" { - targets = [ - "ruby3-3", - "ruby3-3-webapp", - - "ruby3-2", - "ruby3-2-webapp", - - "ruby3-1", - "ruby3-1-webapp", - - "ruby3-0", - "ruby3-0-webapp", - - "ruby2-7", - "ruby2-7-webapp", - ] -} - -target "ruby3-3" { - dockerfile = "Dockerfile" - tags = [ - "nullstone/rails:ruby3.3", - "nullstone/rails:ruby3", - "nullstone/rails", - ] - args = { - "RUBY_VERSION" = "3.3" - } -} - -target "ruby3-3-webapp" { - dockerfile = "webapp/Dockerfile" - tags = [ - "nullstone/rails:ruby3.3-webapp", - "nullstone/rails:ruby3-webapp", - "nullstone/rails:webapp" - ] - args = { - "RUBY_VERSION" = "3.3" - } -} - -group "group-ruby3-2" { - targets = [ - "ruby3-2", - "ruby3-2-webapp", - ] -} - -target "ruby3-2" { - dockerfile = "Dockerfile" - tags = ["nullstone/rails:ruby3.2"] - args = { - "RUBY_VERSION" = "3.2.2" - } -} - -target "ruby3-2-webapp" { - dockerfile = "webapp/Dockerfile" - tags = ["nullstone/rails:ruby3.2-webapp"] - args = { - "RUBY_VERSION" = "3.2.2" - } +variable "RUBY_VERSION" { + default = "3.4" } -group "group-ruby3-1" { - targets = [ - "ruby3-1", - "ruby3-1-webapp", - ] -} - -target "ruby3-1" { - dockerfile = "Dockerfile" - tags = [ - "nullstone/rails:ruby3.1", - ] - args = { - "RUBY_VERSION" = "3.1" - } -} - -target "ruby3-1-webapp" { - dockerfile = "webapp/Dockerfile" - tags = [ - "nullstone/rails:ruby3.1-webapp", - ] - args = { - "RUBY_VERSION" = "3.1" - } -} - -group "group-ruby3-0" { - targets = [ - "ruby3-0", - "ruby3-0-webapp", - ] -} - -target "ruby3-0" { - dockerfile = "Dockerfile" - tags = [ - "nullstone/rails:ruby3.0" - ] - args = { - "RUBY_VERSION" = "3.0" - } -} - -target "ruby3-0-webapp" { - dockerfile = "webapp/Dockerfile" - tags = [ - "nullstone/rails:ruby3.0-webapp" - ] - args = { - "RUBY_VERSION" = "3.0" - } -} - -group "group-ruby2-7" { - targets = [ - "ruby2-7", - "ruby2-7-webapp", - ] +group "default" { + targets = ["normal", "webapp"] } -target "ruby2-7" { +target "normal" { dockerfile = "Dockerfile" - tags = [ - "nullstone/rails:ruby2.7" - ] + tags = ["nullstone/rails:ruby${RUBY_VERSION}"] args = { - "RUBY_VERSION" = "2.7" + RUBY_VERSION = RUBY_VERSION } } -target "ruby2-7-webapp" { +target "webapp" { dockerfile = "webapp/Dockerfile" - tags = [ - "nullstone/rails:ruby2.7-webapp" - ] + tags = ["nullstone/rails:ruby${RUBY_VERSION}-webapp"] args = { - "RUBY_VERSION" = "2.7" + RUBY_VERSION = RUBY_VERSION } } diff --git a/ruby_versions.txt b/ruby_versions.txt new file mode 100644 index 0000000..83a5389 --- /dev/null +++ b/ruby_versions.txt @@ -0,0 +1,27 @@ +3.4 +3.4.1 +3.4.2 +3.3 +3.3.0 +3.3.1 +3.3.2 +3.3.3 +3.3.4 +3.3.5 +3.3.6 +3.3.7 +3.2 +3.2.0 +3.2.1 +3.2.2 +3.2.3 +3.2.4 +3.2.5 +3.2.6 +3.2.7 +3.1 +3.1.6 +3.0 +3.0.7 +2.7 +2.7.8 From 5546ab0e475d0db27bd1fc4748214f0f37b46d4d Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Wed, 19 Mar 2025 13:05:55 -0400 Subject: [PATCH 5/8] Install bundler in docker build --- Dockerfile | 3 ++- docker-entrypoint.d/30-bundle-install.sh | 3 --- webapp/Dockerfile | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 51d6e6a..bd862a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,10 @@ WORKDIR /docker-entrypoint.d COPY docker-entrypoint.d/*.sh . RUN chmod +x /docker-entrypoint.d/*.sh -# Set up bundle path +# Set up bundler RUN mkdir -p /usr/local/bundle ENV BUNDLE_PATH=/usr/local/bundle +RUN gem install bundler # Set up pid file RUN mkdir -p /var/run/ diff --git a/docker-entrypoint.d/30-bundle-install.sh b/docker-entrypoint.d/30-bundle-install.sh index c416296..2146762 100644 --- a/docker-entrypoint.d/30-bundle-install.sh +++ b/docker-entrypoint.d/30-bundle-install.sh @@ -3,9 +3,6 @@ set -ex if [ "${NULLSTONE_ENV}" = "local" ]; then - echo "Installing bundler..." - gem install bundler - echo "Verifying and installing gems..." bundle check || bundle install else diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 63f53b4..388947b 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -23,9 +23,10 @@ WORKDIR /docker-entrypoint.d COPY docker-entrypoint.d/*.sh . RUN chmod +x /docker-entrypoint.d/*.sh -# Set up bundle path +# Set up bundler RUN mkdir -p /usr/local/bundle ENV BUNDLE_PATH=/usr/local/bundle +RUN gem install bundler # Set up pid file RUN mkdir -p /var/run/ From 67055dd3a480eb4a3d5f10daf09789d146187a58 Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Wed, 19 Mar 2025 13:22:12 -0400 Subject: [PATCH 6/8] fix bundler install --- Dockerfile | 5 +++-- docker-entrypoint.d/10-remove-pid.sh | 2 +- docker-entrypoint.d/20-database-url.sh | 2 +- docker-entrypoint.d/30-bundle-install.sh | 2 +- docker-entrypoint.d/40-node-install.sh | 2 +- webapp/Dockerfile | 5 +++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index bd862a5..75eddda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,8 @@ RUN apk add --no-cache --update \ build-base \ postgresql-client \ postgresql-dev \ - tzdata + tzdata \ + bash # Set up entrypoint WORKDIR / @@ -19,7 +20,7 @@ RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundler RUN mkdir -p /usr/local/bundle ENV BUNDLE_PATH=/usr/local/bundle -RUN gem install bundler +RUN gem install bundler || gem install bundler -v 2.4.22 # This fallback supports older versions of ruby/bundler # Set up pid file RUN mkdir -p /var/run/ diff --git a/docker-entrypoint.d/10-remove-pid.sh b/docker-entrypoint.d/10-remove-pid.sh index d94bbfa..92fc33c 100644 --- a/docker-entrypoint.d/10-remove-pid.sh +++ b/docker-entrypoint.d/10-remove-pid.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -ex +set -e echo "Removing pid file" rm -f "${PIDFILE}" diff --git a/docker-entrypoint.d/20-database-url.sh b/docker-entrypoint.d/20-database-url.sh index ddaaa88..60d2c30 100644 --- a/docker-entrypoint.d/20-database-url.sh +++ b/docker-entrypoint.d/20-database-url.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -ex +set -e # Configure DATABASE_URL if POSTGRES_URL is set if [ -n "${POSTGRES_URL}" ]; then diff --git a/docker-entrypoint.d/30-bundle-install.sh b/docker-entrypoint.d/30-bundle-install.sh index 2146762..42c3803 100644 --- a/docker-entrypoint.d/30-bundle-install.sh +++ b/docker-entrypoint.d/30-bundle-install.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -ex +set -e if [ "${NULLSTONE_ENV}" = "local" ]; then echo "Verifying and installing gems..." diff --git a/docker-entrypoint.d/40-node-install.sh b/docker-entrypoint.d/40-node-install.sh index f7d5090..fcc428d 100644 --- a/docker-entrypoint.d/40-node-install.sh +++ b/docker-entrypoint.d/40-node-install.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -ex +set -e if [ "${NULLSTONE_ENV}" = "local" ]; then if [ -f "yarn.lock" ]; then diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 388947b..dc627ad 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -6,7 +6,8 @@ RUN apk add --no-cache --update \ postgresql-client \ postgresql-dev \ nodejs yarn \ - tzdata + tzdata \ + bash VOLUME /etc/nginx/conf.d VOLUME /etc/nginx/templates @@ -26,7 +27,7 @@ RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundler RUN mkdir -p /usr/local/bundle ENV BUNDLE_PATH=/usr/local/bundle -RUN gem install bundler +RUN gem install bundler || gem install bundler -v 2.4.22 # This fallback supports older versions of ruby/bundler # Set up pid file RUN mkdir -p /var/run/ From 05355bc497c4b450a2b640a0672cb2e2c411a430 Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Wed, 19 Mar 2025 13:29:28 -0400 Subject: [PATCH 7/8] added git, npm, and vim to docker images --- Dockerfile | 3 ++- webapp/Dockerfile | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 75eddda..623f425 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,9 @@ RUN apk add --no-cache --update \ build-base \ postgresql-client \ postgresql-dev \ + git \ tzdata \ - bash + vim bash # Set up entrypoint WORKDIR / diff --git a/webapp/Dockerfile b/webapp/Dockerfile index dc627ad..0650e36 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -5,9 +5,10 @@ RUN apk add --no-cache --update \ build-base \ postgresql-client \ postgresql-dev \ - nodejs yarn \ + git \ + nodejs npm yarn \ tzdata \ - bash + vim bash VOLUME /etc/nginx/conf.d VOLUME /etc/nginx/templates From 77fd2f17ca834039a36bcc41e495477eb0221213 Mon Sep 17 00:00:00 2001 From: Brad Sickles Date: Thu, 20 Mar 2025 16:28:26 -0400 Subject: [PATCH 8/8] don't add node-install entrypoint to normal docker image, only webapp --- Dockerfile | 4 +++- webapp/Dockerfile | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 623f425..dc40e0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,9 @@ COPY docker-entrypoint.sh . RUN chmod +x /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"] WORKDIR /docker-entrypoint.d -COPY docker-entrypoint.d/*.sh . +COPY docker-entrypoint.d/10-remove-pid.sh . +COPY docker-entrypoint.d/20-database-url.sh . +COPY docker-entrypoint.d/30-bundle-install.sh . RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundler diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 0650e36..df09c1d 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -22,7 +22,10 @@ COPY docker-entrypoint.sh . RUN chmod +x /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"] WORKDIR /docker-entrypoint.d -COPY docker-entrypoint.d/*.sh . +COPY docker-entrypoint.d/10-remove-pid.sh . +COPY docker-entrypoint.d/20-database-url.sh . +COPY docker-entrypoint.d/30-bundle-install.sh . +COPY docker-entrypoint.d/40-node-install.sh . RUN chmod +x /docker-entrypoint.d/*.sh # Set up bundler