From daa1f290f2485f4f23cfdbbb8a4ac522e4427385 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 1 Mar 2026 04:03:47 +0000 Subject: [PATCH 1/3] Add Docker, Docker Compose, and GitHub Actions CI support - Added a production-ready `Dockerfile` based on Ruby 3.3.8-bullseye. - Added `entrypoint.sh` to handle Rails server PID cleanup. - Added `.dockerignore` to optimize build context. - Added `docker-compose.yml` for local orchestration of Rails, PostgreSQL 17, and Elasticsearch 7.4.0. - Added GitHub Actions workflow in `.github/workflows/docker-build-push.yml` to build and push the image to GHCR on pushes to the `dev` branch. Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com> --- .dockerignore | 31 ++++++++++ .github/workflows/docker-build-push.yml | 43 ++++++++++++++ Dockerfile | 52 +++++++++++++++++ docker-compose.yml | 76 +++++++++++++++++++++++++ entrypoint.sh | 8 +++ 5 files changed, 210 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker-build-push.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..63c9e553fd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,31 @@ +.git +.github +.devcontainer +log/* +tmp/* +!tmp/keep +node_modules +public/assets +.env +.ruby-version +.ruby-gemset +.editorconfig +.esignore +.eslintrc.json +.haml-lint.yml +.overcommit.yml +.rspec +.rubocop.yml +.rubocop_todo.yml +.scss-lint.yml +.travis.yml +.yamllint +CODE_OF_CONDUCT.md +CONTRIBUTING.md +CONTRIBUTORS.md +LICENSE.txt +README.md +TECH.md +docker-compose.yml +Dockerfile +.dockerignore diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000000..01b561bfc9 --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -0,0 +1,43 @@ +name: Docker Build and Push + +on: + push: + branches: + - dev + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..c4226123ae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +FROM ruby:3.3.8-bullseye + +# Install system dependencies +RUN apt-get update -qq && \ + apt-get install -y --no-install-recommends \ + build-essential \ + libpq-dev \ + git \ + curl \ + gnupg2 \ + shared-mime-info \ + libvips \ + && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ + && apt-get install -y --no-install-recommends nodejs \ + && npm install -g yarn \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Set production environment +ENV RAILS_ENV=production \ + BUNDLE_WITHOUT="development test" \ + RAILS_SERVE_STATIC_FILES=true \ + RAILS_LOG_TO_STDOUT=true + +WORKDIR /app + +# Install gems +COPY Gemfile Gemfile.lock ./ +RUN bundle config set --local deployment 'true' && \ + bundle config set --local without 'development test' && \ + bundle install --jobs 4 --retry 3 + +# Install JavaScript dependencies +COPY package.json yarn.lock ./ +RUN yarn install --check-files + +# Copy the application code +COPY . . + +# Precompile assets +# Secret key base is needed for asset compilation but doesn't need to be the real one +RUN RAILS_ENV=production SECRET_KEY_BASE_DUMMY=1 bundle exec rake assets:precompile + +# Add a script to be executed every time the container starts. +COPY entrypoint.sh /usr/bin/ +RUN chmod +x /usr/bin/entrypoint.sh +ENTRYPOINT ["entrypoint.sh"] + +EXPOSE 3000 + +# Start the main process. +CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..fe059d58b9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,76 @@ +version: '3.8' + +services: + web: + build: . + ports: + - "3000:3000" + depends_on: + db: + condition: service_healthy + elasticsearch: + condition: service_healthy + environment: + DATABASE_URL: postgresql://postgres:postgres@db:5432/growstuff_prod + ELASTICSEARCH_URL: http://elasticsearch:9200/ + RAILS_ENV: production + RAILS_LOG_TO_STDOUT: "true" + RAILS_SERVE_STATIC_FILES: "true" + APP_DOMAIN_NAME: localhost:3000 + APP_PROTOCOL: http + DEVISE_SECRET_KEY: secret + GROWSTUFF_EMAIL: "noreply@test.growstuff.org" + GROWSTUFF_FLICKR_KEY: secretkey + GROWSTUFF_FLICKR_SECRET: secretsecret + GROWSTUFF_SITE_NAME: "Growstuff (local)" + RAILS_SECRET_TOKEN: supersecret + SECRET_KEY_BASE: supersecretbase + + db: + image: postgres:17 + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + - .devcontainer/create-db-user.sql:/docker-entrypoint-initdb.d/create-db-user.sql + environment: + POSTGRES_USER: postgres + POSTGRES_DB: growstuff_prod + POSTGRES_PASSWORD: postgres + ports: + - "5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 + + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:7.4.0 + container_name: elasticsearch + restart: unless-stopped + environment: + - xpack.security.enabled=false + - discovery.type=single-node + ulimits: + memlock: + soft: -1 + hard: -1 + nofile: + soft: 65536 + hard: 65536 + cap_add: + - IPC_LOCK + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:9200 | grep tagline"] + interval: 10s + timeout: 10s + retries: 120 + volumes: + - esdata01:/usr/share/elasticsearch/data + ports: + - 9200:9200 + - 9300:9300 + +volumes: + postgres-data: + esdata01: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000000..9b7e12d0bd --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +# Remove a potentially pre-existing server.pid for Rails. +rm -f /app/tmp/pids/server.pid + +# Then exec the container's main process (what's set as CMD in the Dockerfile). +exec "$@" From be7a14d5a50c0eb4fc1117033feab4d4b83f5d80 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 1 Mar 2026 05:13:31 +0000 Subject: [PATCH 2/3] Swap to 3.4.8 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c4226123ae..57dabaef8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.3.8-bullseye +FROM ruby:3.4.8-trixie # Install system dependencies RUN apt-get update -qq && \ From 83dd6baab0684a6f71f6d92f28a6600a2cde4e73 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sun, 1 Mar 2026 05:14:18 +0000 Subject: [PATCH 3/3] Node 22 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 57dabaef8f..d7caad51ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apt-get update -qq && \ gnupg2 \ shared-mime-info \ libvips \ - && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ + && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && apt-get install -y --no-install-recommends nodejs \ && npm install -g yarn \ && apt-get clean \