Skip to content

Commit 6e7a376

Browse files
authored
Github Codespaces configuration
1 parent e9f38a1 commit 6e7a376

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby/.devcontainer/base.Dockerfile
2+
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}
6+
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+
# [Optional] Uncomment this section to install additional OS packages.
12+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
13+
&& apt-get -y install --no-install-recommends \
14+
mariadb-server libmariadbclient-dev \
15+
postgresql postgresql-client postgresql-contrib libpq-dev \
16+
redis-server memcached \
17+
imagemagick ffmpeg mupdf mupdf-tools libvips
18+
19+
20+
# [Optional] Uncomment this line to install additional gems.
21+
# RUN gem install <your-gem-names-here>
22+
23+
# [Optional] Uncomment this line to install global node packages.
24+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/boot.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
bundle install
2+
yarn install
3+
4+
sudo service postgresql start
5+
sudo service mysql start
6+
sudo service redis-server start
7+
sudo service memcached start
8+
9+
# Create PostgreSQL users and databases
10+
sudo su postgres -c "createuser --superuser vscode"
11+
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest"
12+
sudo su postgres -c "createdb -O vscode -E UTF8 -T template0 activerecord_unittest2"
13+
14+
# Create MySQL database and databases
15+
MYSQL_PWD=root sudo mysql -uroot <<SQL
16+
CREATE USER 'rails'@'localhost';
17+
CREATE DATABASE activerecord_unittest DEFAULT CHARACTER SET utf8mb4;
18+
CREATE DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8mb4;
19+
GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost';
20+
GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost';
21+
GRANT ALL PRIVILEGES ON inexistent_activerecord_unittest.* to 'rails'@'localhost';
22+
SQL

.devcontainer/devcontainer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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
3+
{
4+
"name": "Ruby",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
// Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
9+
"VARIANT": "3",
10+
// Options
11+
"NODE_VERSION": "lts/*"
12+
}
13+
},
14+
15+
// Set *default* container specific settings.json values on container create.
16+
"settings": {},
17+
18+
// Add the IDs of extensions you want installed when the container is created.
19+
"extensions": [
20+
"rebornix.Ruby"
21+
],
22+
23+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
24+
// "forwardPorts": [],
25+
26+
// Use 'postCreateCommand' to run commands after the container is created.
27+
"postCreateCommand": ".devcontainer/boot.sh",
28+
29+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
30+
"remoteUser": "vscode"
31+
32+
}

0 commit comments

Comments
 (0)