-
-
Notifications
You must be signed in to change notification settings - Fork 12
Give the suite somewhere to run that is not the deploy host #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
openipc-ai
wants to merge
2
commits into
master
Choose a base branch
from
chore/dev-container
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Local development and test stack. | ||
| # | ||
| # This is the stack you develop against; it is not how the site is deployed. | ||
| # Production runs the root Dockerfile as a container behind the host's nginx -- | ||
| # see deploy/docker-compose.yml and deploy/DEV-VALIDATION.md. | ||
| # | ||
| # docker compose run --rm web bundle install # first time, and after Gemfile changes | ||
| # docker compose run --rm web yarn install --immutable | ||
| # docker compose run --rm web bin/rails db:prepare | ||
| # docker compose run --rm web bin/rails test | ||
| # docker compose run --rm web bundle exec rubocop | ||
| # docker compose run --rm web bundle exec i18n-tasks missing | ||
| # | ||
| # `bundle exec` for the development-group tools: BUNDLE_BIN puts binstubs on | ||
| # PATH, but bundler only writes one for a gem that ships an executable it knows | ||
| # about at install time, and rubocop's is not there. | ||
| # | ||
| # `docker compose up web` serves http://localhost:3010, but the JS and CSS | ||
| # bundles are built separately -- app/assets/builds/ is gitignored, and | ||
| # Sprockets raises on any page that goes through the layout until they exist: | ||
| # | ||
| # docker compose run --rm web yarn build | ||
| # docker compose run --rm web yarn build:css | ||
| services: | ||
| db: | ||
| # Matches the MariaDB that CI runs the suite against. 11.8 defaults utf8mb4 | ||
| # to uca1400_ai_ci rather than general_ci, which is why config/database.yml | ||
| # pins the collation rather than inheriting it. | ||
| image: mariadb:11.8 | ||
| environment: | ||
| MARIADB_ROOT_PASSWORD: root | ||
| MARIADB_USER: www | ||
| MARIADB_PASSWORD: www | ||
| MARIADB_DATABASE: openipc_development | ||
| volumes: | ||
| - db-data:/var/lib/mysql | ||
| - ./docker/db-init.sql:/docker-entrypoint-initdb.d/90-grants.sql:ro | ||
| healthcheck: | ||
| test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized'] | ||
| interval: 3s | ||
| timeout: 5s | ||
| retries: 20 | ||
|
|
||
| web: | ||
| build: | ||
| # ./docker, not the repository root: the image copies nothing from the | ||
| # tree, and a root context would ship node_modules to the daemon. | ||
| context: ./docker | ||
| dockerfile: Dockerfile.dev | ||
| args: | ||
| DEV_UID: ${DEV_UID:-1000} | ||
| DEV_GID: ${DEV_GID:-1000} | ||
| # Matched to the build args above so files written into the bind-mounted | ||
| # tree belong to you. If `id -u` is not 1000, put your ids in a .env file | ||
| # beside this one and rebuild: | ||
| # | ||
| # printf 'DEV_UID=%s\\nDEV_GID=%s\\n' "$(id -u)" "$(id -g)" > .env | ||
| # docker compose build web | ||
| # | ||
| # Compose reads .env automatically; it is gitignored. | ||
| user: ${DEV_UID:-1000}:${DEV_GID:-1000} | ||
| command: bash -c 'bundle check || bundle install; exec bin/rails server -b 0.0.0.0 -p 3010' | ||
| environment: | ||
| # Setting this is what makes config/database.yml connect over TCP instead | ||
| # of the /run/mysqld socket, which does not exist in this container. | ||
| OPENIPC_DATABASE_HOST: db | ||
| OPENIPC_DATABASE_PORT: 3306 | ||
| ports: | ||
| - '3010:3010' | ||
| volumes: | ||
| - .:/app | ||
| # /bundle is a named volume rather than part of the tree, so `bundle | ||
| # install` survives a rebuild. It works with the non-root user above | ||
| # because the image creates and chowns /bundle before the volume is | ||
| # populated from it -- Docker seeds an empty named volume from the image, | ||
| # ownership included. | ||
| # | ||
| # node_modules deliberately gets no such volume: an empty named volume is | ||
| # created root-owned with nothing in the image to seed it from, so yarn | ||
| # would fail with EACCES on the first link step. It lives in the bind mount | ||
| # instead, where it belongs to you and is already gitignored. | ||
| - bundle:/bundle | ||
| depends_on: | ||
| db: | ||
| condition: service_healthy | ||
|
|
||
| volumes: | ||
| bundle: | ||
| db-data: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Development and test image for the openipc.org Rails app. | ||
| # | ||
| # This is NOT the image that serves traffic -- that is the Dockerfile at the | ||
| # repository root, which is a two-stage production build. This one exists so the | ||
| # suite, rubocop and i18n-tasks can be run on a machine whose system Ruby is not | ||
| # 3.1.7, which is every machine we develop on. | ||
| # | ||
| # It carries only the OS libraries the gem set binds to. The application itself | ||
| # is bind-mounted by compose.yaml and gems install at runtime into a persistent | ||
| # volume, so a source change never rebuilds this image. | ||
| # | ||
| # The build context is ./docker, not the repository root: nothing here copies | ||
| # the application in, and a root context would ship the whole tree (node_modules | ||
| # and all) to the daemon on every build. | ||
|
|
||
| # Matches the production image and .ruby-version. Do not drift: a gem that | ||
| # compiles here has to compile there. | ||
| FROM ruby:3.1.7-slim-bookworm | ||
|
|
||
| ARG NODE_MAJOR=20 | ||
|
|
||
| # build-essential is not optional: sassc compiles libsass from source and | ||
| # mysql2 needs the libmysqlclient headers. | ||
| # | ||
| # libvips42 and libheif1 come from the OS, not from the 'vips' gem -- the gem | ||
| # ships its own prebuilt libvips and shadowed the system copy. Snapshot's HEIF | ||
| # uploads only decode if libvips was built against libheif, which the Debian | ||
| # package is. | ||
| RUN apt-get update -qq && apt-get install --no-install-recommends -y \ | ||
| build-essential \ | ||
| ca-certificates \ | ||
| curl \ | ||
| default-libmysqlclient-dev \ | ||
| default-mysql-client \ | ||
| git \ | ||
| gnupg \ | ||
| libffi-dev \ | ||
| libheif1 \ | ||
| libssl-dev \ | ||
| libvips42 \ | ||
| libyaml-dev \ | ||
| pkg-config \ | ||
| zlib1g-dev \ | ||
| && curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \ | ||
| && apt-get install --no-install-recommends -y nodejs \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # The project is on Yarn 4 (Berry); yarn.lock carries the __metadata header and | ||
| # a v1 yarn cannot read it. corepack resolves the exact version from the | ||
| # "packageManager" field in package.json, the same way the production image does. | ||
| ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 | ||
| RUN corepack enable | ||
|
|
||
| # Gems live in a named volume so `bundle install` survives a container restart | ||
| # and does not fight the bind-mounted source tree. | ||
| # | ||
| # RUBYOPT is not cosmetic. Ruby 3.1 auto-activates its own bundled | ||
| # error_highlight 0.3.0 before Bundler runs, and the Gemfile's development group | ||
| # asks for >= 0.4.0, which resolves to 0.5.1 -- so `bin/rails` dies at | ||
| # config/boot.rb with "You have already activated error_highlight 0.3.0". | ||
| # Disabling the startup require lets Bundler activate the locked version. | ||
| # | ||
| # Neither the production image nor CI hits this, because both exclude the | ||
| # development group (BUNDLE_WITHOUT); this container is the only place that | ||
| # installs it, and it has to, because rubocop and i18n-tasks live there. | ||
| # | ||
| # Upgrading RubyGems does NOT fix it -- `gem update --system 3.4.22` was tried | ||
| # and the conflict is unchanged. The flag is the whole fix. | ||
| ENV BUNDLE_PATH=/bundle \ | ||
| BUNDLE_BIN=/bundle/bin \ | ||
| PATH=/bundle/bin:$PATH \ | ||
| RUBYOPT=--disable-error_highlight | ||
|
|
||
| # Run as the developer, not as root. | ||
| # | ||
| # Everything this container writes into the bind-mounted tree -- app/assets/builds, | ||
| # log/, tmp/, and anything `yarn build:fonts` produces -- lands on the host with | ||
| # the writer's ownership. As root that means files the developer cannot delete or | ||
| # edit, which is how public/fonts/ ended up owned by nobody:nogroup the first time | ||
| # this stack was used in anger. | ||
| # | ||
| # The uid has to exist in the image and own /bundle, or bundler cannot install | ||
| # into the volume. 1000 is the usual first user on a Linux desktop; override with | ||
| # DEV_UID/DEV_GID when it is not (see compose.yaml). | ||
| ARG DEV_UID=1000 | ||
| ARG DEV_GID=1000 | ||
| RUN groupadd --gid ${DEV_GID} dev 2>/dev/null || true \ | ||
| && useradd --uid ${DEV_UID} --gid ${DEV_GID} --create-home --shell /bin/bash dev 2>/dev/null || true \ | ||
| && mkdir -p /bundle \ | ||
| && chown -R ${DEV_UID}:${DEV_GID} /bundle | ||
|
|
||
| USER ${DEV_UID}:${DEV_GID} | ||
|
|
||
| WORKDIR /app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| -- The compose environment creates openipc_development and grants www on it. | ||
| -- The suite needs more than that: openipc_test, plus one database per Minitest | ||
| -- worker (openipc_test-0, openipc_test-1, ... -- the suite is parallelized | ||
| -- across cores), and those are created by Rails at run time under the www user. | ||
| -- | ||
| -- The backslash escapes the underscore so it is matched literally rather than | ||
| -- as MySQL's single-character wildcard; without it the grant would also cover | ||
| -- databases like "openipcXfoo". | ||
| CREATE DATABASE IF NOT EXISTS openipc_test | ||
| CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; | ||
| GRANT ALL PRIVILEGES ON `openipc\_%`.* TO 'www'@'%'; | ||
| FLUSH PRIVILEGES; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.