Skip to content

Commit b8501c6

Browse files
authored
Merge branch 'rails:main' into improve_conf-hosts_documentation
2 parents 592650c + 17cde11 commit b8501c6

File tree

3,070 files changed

+172613
-105574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,070 files changed

+172613
-105574
lines changed

.devcontainer/Dockerfile

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
11
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby/.devcontainer/base.Dockerfile
22

3-
# [Choice] Ruby version: 3, 3.0, 2, 2.7, 2.6
4-
ARG VARIANT="3.0"
5-
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
3+
# [Choice] Ruby version: 3.4, 3.3, 3.2
4+
ARG VARIANT="3.4.3"
5+
FROM ghcr.io/rails/devcontainer/images/ruby:${VARIANT}
66

7-
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8-
ARG NODE_VERSION="none"
9-
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10-
11-
COPY .devcontainer/library-scripts/github-debian.sh /tmp/library-scripts/
12-
RUN apt-get update && bash /tmp/library-scripts/github-debian.sh
13-
14-
# [Optional] Uncomment this section to install additional OS packages.
15-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
16-
&& apt-get -y install --no-install-recommends \
17-
mariadb-server libmariadb-dev \
18-
postgresql postgresql-client postgresql-contrib libpq-dev \
19-
redis-server memcached \
20-
ffmpeg mupdf mupdf-tools libvips poppler-utils
21-
22-
23-
ARG IMAGEMAGICK_VERSION="7.1.0-5"
24-
RUN wget -qO /tmp/im.tar.xz https://imagemagick.org/archive/releases/ImageMagick-$IMAGEMAGICK_VERSION.tar.xz \
25-
&& wget -qO /tmp/im.sig https://imagemagick.org/archive/releases/ImageMagick-$IMAGEMAGICK_VERSION.tar.xz.asc \
26-
&& gpg --batch --keyserver keyserver.ubuntu.com --recv 89AB63D48277377A \
27-
&& gpg --batch --verify /tmp/im.sig /tmp/im.tar.xz \
28-
&& tar xJf /tmp/im.tar.xz -C /tmp \
29-
&& cd /tmp/ImageMagick-$IMAGEMAGICK_VERSION \
30-
&& ./configure --with-rsvg && make -j 9 && make install \
31-
&& ldconfig /usr/local/lib \
32-
&& rm -rf /tmp/*
7+
RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \
8+
&& sudo apt-get -y install --no-install-recommends \
9+
mariadb-client libmariadb-dev \
10+
postgresql-client postgresql-contrib libpq-dev \
11+
ffmpeg mupdf mupdf-tools libvips-dev poppler-utils \
12+
libxml2-dev sqlite3 imagemagick
3313

3414
# Add the Rails main Gemfile and install the gems. This means the gem install can be done
3515
# during build instead of on start. When a fork or branch has different gems, we still have an
@@ -48,7 +28,11 @@ COPY activerecord/activerecord.gemspec /tmp/rails/activerecord/
4828
COPY activestorage/activestorage.gemspec /tmp/rails/activestorage/
4929
COPY activesupport/activesupport.gemspec /tmp/rails/activesupport/
5030
COPY railties/railties.gemspec /tmp/rails/railties/
31+
COPY tools/releaser/releaser.gemspec /tmp/rails/tools/releaser/
32+
# Docker does not support COPY as users other than root. So we need to chown this dir so we
33+
# can bundle as vscode user and then remove the tmp dir
34+
RUN sudo chown -R vscode:vscode /tmp/rails
35+
USER vscode
5136
RUN cd /tmp/rails \
52-
&& bundle install \
53-
&& yarn install \
37+
&& /home/vscode/.rbenv/shims/bundle install \
5438
&& rm -rf /tmp/rails

.devcontainer/boot.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
#!/bin/sh
2+
3+
bundle update --bundler
14
bundle install
2-
yarn install
35

4-
sudo chown -R vscode:vscode /usr/local/bundle
6+
if [ -n "${NVM_DIR}" ]; then
7+
# shellcheck disable=SC1091
8+
. "${NVM_DIR}/nvm.sh" && nvm install --lts
9+
yarn install
10+
fi
511

6-
sudo service postgresql start
7-
sudo service mariadb start
8-
sudo service redis-server start
9-
sudo service memcached start
12+
cd activerecord || { echo "activerecord directory doesn't exist"; exit; }
1013

11-
# Create PostgreSQL users and databases
12-
sudo su postgres -c "createuser --superuser vscode"
13-
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest"
14-
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest2"
14+
# Create PostgreSQL databases
15+
bundle exec rake db:postgresql:rebuild
1516

16-
# Create MySQL database and databases
17-
cd activerecord
18-
MYSQL_CODESPACES=1 bundle exec rake db:mysql:build
17+
# Create MySQL databases
18+
bundle exec rake db:mysql:rebuild

.devcontainer/compose.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
services:
2+
rails:
3+
build:
4+
context: ..
5+
dockerfile: .devcontainer/Dockerfile
6+
7+
volumes:
8+
- ../..:/workspaces:cached
9+
10+
# Overrides default command so things don't shut down after the process ends.
11+
command: sleep infinity
12+
13+
depends_on:
14+
- postgres
15+
- mysql
16+
- redis
17+
- memcached
18+
19+
environment:
20+
MYSQL_CODESPACES: "1"
21+
22+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
23+
# (Adding the "ports" property to this file will not forward from a Codespace.)
24+
25+
postgres:
26+
image: postgres:latest
27+
restart: unless-stopped
28+
volumes:
29+
- postgres-data:/var/lib/postgresql/data
30+
environment:
31+
POSTGRES_USER: postgres
32+
POSTGRES_DB: postgres
33+
POSTGRES_PASSWORD: postgres
34+
35+
mysql:
36+
image: mysql:latest
37+
restart: unless-stopped
38+
volumes:
39+
- mysql-data:/var/lib/mysql
40+
environment:
41+
MYSQL_ROOT_PASSWORD: root
42+
43+
redis:
44+
image: valkey/valkey:8
45+
restart: unless-stopped
46+
volumes:
47+
- redis-data:/data
48+
49+
memcached:
50+
image: memcached:latest
51+
restart: unless-stopped
52+
command: ["-m", "1024"]
53+
54+
volumes:
55+
postgres-data:
56+
mysql-data:
57+
redis-data:

.devcontainer/devcontainer.json

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby
1+
// For format details, see https://containers.dev/implementors/json_reference/.
32
{
4-
"name": "Ruby",
5-
"build": {
6-
"dockerfile": "Dockerfile",
7-
"context": "..",
8-
"args": {
9-
// Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
10-
"VARIANT": "3",
11-
// Options
12-
"NODE_VERSION": "lts/*"
3+
"name": "Rails project development",
4+
"dockerComposeFile": "compose.yaml",
5+
"service": "rails",
6+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7+
8+
// Features to add to the dev container. More info: https://containers.dev/features.
9+
"features": {
10+
"ghcr.io/devcontainers/features/github-cli:1": {
11+
"version": "latest"
12+
},
13+
"ghcr.io/devcontainers/features/node:1": {
14+
"version": "latest"
15+
},
16+
"ghcr.io/rails/devcontainer/features/postgres-client:1.1.1": {
17+
"version": "17"
1318
}
1419
},
1520

16-
// Set *default* container specific settings.json values on container create.
17-
"settings": {},
18-
19-
// Add the IDs of extensions you want installed when the container is created.
20-
"extensions": [
21-
"rebornix.Ruby"
22-
],
21+
"containerEnv": {
22+
"PGHOST": "postgres",
23+
"PGUSER": "postgres",
24+
"PGPASSWORD": "postgres",
25+
"MYSQL_HOST": "mysql",
26+
"REDIS_URL": "redis://redis/0",
27+
"MEMCACHE_SERVERS": "memcached:11211"
28+
},
2329

2430
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25-
// "forwardPorts": [],
31+
// This can be used to network with other containers or the host.
32+
// "forwardPorts": [3000, 5432],
2633

2734
// Use 'postCreateCommand' to run commands after the container is created.
2835
"postCreateCommand": ".devcontainer/boot.sh",
2936

30-
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
31-
"remoteUser": "vscode"
37+
// Configure tool-specific properties.
38+
"customizations": {
39+
"vscode": {
40+
// Add the IDs of extensions you want installed when the container is created.
41+
"extensions": [
42+
"Shopify.ruby-lsp"
43+
]
44+
}
45+
}
3246

47+
// Uncomment to connect as root instead. More info: https://containers.dev/implementors/json_reference/#remoteUser.
48+
// "remoteUser": "root"
3349
}

0 commit comments

Comments
 (0)