Skip to content
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

Add devcontainer #1446

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ruby:3.3-alpine

RUN apk update && apk add curl gcc g++ gnupg make build-base ca-certificates socat git htop tzdata imagemagick ruby-dev openssl libpq-dev libxml2-dev libxslt-dev nodejs-current npm yarn cmake clang clang-dev gcompat

RUN curl https://get.acme.sh | sh
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:$PATH"
ENV RUSTFLAGS="-C target-feature=-crt-static"

RUN gem install bundler -v 2.5.3 && \
bundle config set --local path vendor/bundle

WORKDIR /rails
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres
{
"name": "Homeland",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/rails",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or the host.
// "forwardPorts": [3000, 5432],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bundle install && yarn install && bin/rails db:setup"
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
40 changes: 40 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3'

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ..:/rails:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
# network_mode: service:db

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
environment:
DATABASE_URL: postgres://postgres:postgres@postgres:5432
REDIS_URL: redis://redis:6379

postgres:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres

redis:
image: redis:latest
volumes:
- ./tmp/redis:/data

volumes:
postgres-data:
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ config/nginx/nginx.conf
*.sublime-workspace
.rvmrc
vendor/ruby
vendor/bundle
.idea/
spec/examples.txt
.vagrant
Expand Down
19 changes: 13 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ GEM
nokogiri (~> 1.6)
rest-client (~> 2.0)
ast (2.4.2)
autocorrect-rb (2.13.0-aarch64-linux)
rb_sys (>= 0.9.54)
autocorrect-rb (2.13.0-arm64-darwin)
rb_sys (>= 0.9.54)
autocorrect-rb (2.13.0-x86_64-linux)
Expand Down Expand Up @@ -184,6 +186,7 @@ GEM
net-http
faraday-rack (2.0.0)
faraday (~> 2.0)
ffi (1.17.0-aarch64-linux-musl)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
Expand Down Expand Up @@ -287,6 +290,8 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.7.4)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
Expand Down Expand Up @@ -373,9 +378,8 @@ GEM
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rackup (2.2.0)
rack (>= 3)
webrick (~> 1.8)
rails (8.0.0.rc2)
actioncable (= 8.0.0.rc2)
actionmailbox (= 8.0.0.rc2)
Expand Down Expand Up @@ -478,13 +482,16 @@ GEM
ffi (~> 1.12)
logger
ruby2_keywords (0.0.5)
rucaptcha (3.2.3-arm64-darwin)
rucaptcha (3.2.4-aarch64-linux-musl)
railties (>= 3.2)
rb_sys (>= 0.9.86)
rucaptcha (3.2.4-arm64-darwin)
railties (>= 3.2)
rb_sys (>= 0.9.86)
rucaptcha (3.2.3-x86_64-linux)
rucaptcha (3.2.4-x86_64-linux)
railties (>= 3.2)
rb_sys (>= 0.9.86)
rucaptcha (3.2.3-x86_64-linux-musl)
rucaptcha (3.2.4-x86_64-linux-musl)
railties (>= 3.2)
rb_sys (>= 0.9.86)
sass-rails (6.0.0)
Expand Down Expand Up @@ -551,13 +558,13 @@ GEM
method_source (~> 1.0)
warden (1.2.9)
rack (>= 2.0.9)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.7.1)

PLATFORMS
aarch64-linux-musl
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
Expand Down
2 changes: 2 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bin/rails server
js: bin/shakapacker-dev-server
13 changes: 11 additions & 2 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
#!/usr/bin/env ruby
exec "./bin/rails", "server", *ARGV
#!/usr/bin/env sh

if gem list --no-installed --exact --silent foreman; then
echo "Installing foreman..."
gem install foreman
fi

# Default to port 3000 if not specified
export PORT="${PORT:-3000}"

exec foreman start -f Procfile.dev --env /dev/null "$@"
2 changes: 1 addition & 1 deletion test/controllers/api/nodes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe Api::V3::NodesController do
describe "GET /api/nodes.json" do
before do
%w[fun ruby nodes].each_with_index { |n, i| create(:node, name: n, id: i + 1) }
%w[fun ruby nodes].each_with_index { |n, i| create(:node, name: n, id: i + 1, sort: (3 - i)) }
end

it "should return the list of nodes" do
Expand Down
2 changes: 1 addition & 1 deletion test/models/reply_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class ReplyTest < ActiveSupport::TestCase

test ".notification_receiver_ids" do
mentioned_user_ids = [1, 2, 3]
user = create(:user)
user = create(:user, id: 99)
topic = create(:topic, user_id: 10)
reply = create(:reply, user: user, topic: topic, mentioned_user_ids: mentioned_user_ids)

Expand Down
Loading