Skip to content

Commit

Permalink
add devcontainer config
Browse files Browse the repository at this point in the history
  • Loading branch information
chloerei committed Nov 3, 2024
1 parent 1e101ae commit 6be6d69
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
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

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"
}
42 changes: 42 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3'

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

platform: linux/amd64

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

0 comments on commit 6be6d69

Please sign in to comment.