Skip to content

Commit

Permalink
Use Valkey in the devcontainer and remove docker-in-docker configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mrysav committed Nov 17, 2024
1 parent 520c5df commit ff1f4cc
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 35 deletions.
10 changes: 4 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby-rails-postgres
{
"name": "Geneac",
"image": "mcr.microsoft.com/vscode/devcontainers/ruby:3",
"dockerComposeFile": "./docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/geneac",
"shutdownAction": "stopCompose",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"moby": true
},
"ghcr.io/devcontainers/features/sshd:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"onCreateCommand": ".devcontainer/on-create-command.sh",
"postCreateCommand": ".devcontainer/post-create-command.sh",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
3035,
5000
]
}
31 changes: 31 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
app:
image: mcr.microsoft.com/vscode/devcontainers/ruby:3
# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"
# Runs app on the same network as the database container,
# allows "forwardPorts" in devcontainer.json function.
network_mode: service:valkey
depends_on:
- valkey
volumes:
# Mounts the project folder to '/workspaces/geneac'. The target path inside the container
# should match what your application expects. In this case, the compose file is
# in a sub-folder, so you will mount '..'. You would then reference this path as the
# 'workspaceFolder' in '.devcontainer/devcontainer.json' so VS Code starts here.
- ..:/workspaces/geneac:cached

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

valkey:
image: valkey/valkey:8-alpine
command: valkey-server --save 60 1 --loglevel warning
restart: unless-stopped
volumes:
- valkey-data:/data
environment:
MYSQL_ROOT_PASSWORD: blis123

volumes:
valkey-data:
8 changes: 1 addition & 7 deletions .devcontainer/on-create-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ set -euo pipefail

source /usr/local/share/nvm/nvm.sh && nvm install "lts/*" && npm install -g markdownlint-cli 2>&1

# Add Terraform and Azure CLI repositories
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
wget -O- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/azure-cli.list

# Install additional OS packages.
sudo apt-get update
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -y install --no-install-recommends imagemagick libvips42 poppler-utils terraform azure-cli sqlite3
sudo apt-get -y install --no-install-recommends imagemagick libvips42 poppler-utils sqlite3 tmux

# Install overmind
curl -L https://github.com/DarthSim/overmind/releases/download/v2.5.1/overmind-v2.5.1-linux-amd64.gz > /tmp/overmind.gz
Expand Down
2 changes: 0 additions & 2 deletions .devcontainer/post-create-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euo pipefail

docker compose up -d --wait

echo -e "Installing dependencies..."

bundle install
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ GEM
memory_profiler (1.1.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
mini_portile2 (2.8.8)
minitest (5.25.1)
mono_logger (1.1.2)
msgpack (1.7.3)
Expand Down Expand Up @@ -287,7 +287,7 @@ GEM
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.2.0)
rackup (2.2.1)
rack (>= 3)
rails (8.0.0.rc2)
actioncable (= 8.0.0.rc2)
Expand Down Expand Up @@ -407,7 +407,7 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
securerandom (0.3.1)
securerandom (0.3.2)
selectize-rails (0.12.6)
selenium-webdriver (4.26.0)
base64 (~> 0.2)
Expand Down Expand Up @@ -461,7 +461,7 @@ GEM
uc.micro-rb (1.0.6)
unaccent (0.4.0)
unicode-display_width (2.6.0)
uri (1.0.1)
uri (1.0.2)
useragent (0.16.10)
warden (1.2.9)
rack (>= 2.0.9)
Expand Down
8 changes: 0 additions & 8 deletions docker-compose.yml

This file was deleted.

4 changes: 0 additions & 4 deletions script/server
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ set -euo pipefail

cd "$(dirname "$0")/.." || exit 1

docker compose up -d --wait

export OVERMIND_SKIP_ENV=1

overmind start
2 changes: 0 additions & 2 deletions script/setup
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ npm install -g yarn

rbenv install -s

docker compose up -d --wait

bin/rails db:create

exec "$(dirname "$0")/update"
2 changes: 0 additions & 2 deletions script/update
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ bin/bundle install

bin/yarn install

docker compose up -d --wait

bin/rails db:migrate

0 comments on commit ff1f4cc

Please sign in to comment.