Skip to content

Commit 95c9435

Browse files
author
github-actions
committed
update with project-syncing action
1 parent 922ebbc commit 95c9435

File tree

6 files changed

+51
-48
lines changed

6 files changed

+51
-48
lines changed

.devcontainer/devcontainer.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/universal
33
{
44
"name": "Container",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "firstdraft/appdev-rails-8-template",
5+
"dockerComposeFile": "docker-compose.yml", // Location of docker-compose.yml file
6+
"service": "devcontainer", // Where the image is specified in the docker-compose.yml
7+
"workspaceFolder": "/workspaces/ajax-with-magic", // Where to mount the workspace folder
8+
9+
// Container environment variables to ensure database connection works
10+
"containerEnv": {
11+
"PGHOST": "localhost",
12+
"PGUSER": "student",
13+
"PGPASSWORD": "postgres",
14+
"PGDATABASE": "postgres",
15+
"DATABASE_URL": "postgres://student:postgres@localhost:5432/ajax_with_magic?encoding=utf8&pool=5&timeout=5000"
16+
},
717

818
// Features to add to the dev container. More info: https://containers.dev/features.
919
// "features": {},

.devcontainer/docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
services:
2+
devcontainer:
3+
image: firstdraft/appdev-rails-8-template
4+
volumes:
5+
- ../..:/workspaces:cached
6+
network_mode: service:db
7+
command: sleep infinity
8+
9+
db:
10+
image: postgres:16.9
11+
restart: unless-stopped
12+
volumes:
13+
- postgres-data:/var/lib/postgresql/data
14+
environment:
15+
POSTGRES_PASSWORD: postgres
16+
POSTGRES_USER: student
17+
POSTGRES_DB: postgres
18+
19+
redis:
20+
image: redis:latest
21+
restart: unless-stopped
22+
volumes:
23+
- redis-data:/var/lib/redis/data
24+
25+
volumes:
26+
postgres-data:
27+
redis-data:

appdev.rails8.Dockerfile

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,6 @@ RUN /bin/bash -l -c "bundle config set --local path '/home/student/.bundle' && b
6464
&& sudo apt-get update \
6565
&& sudo apt-get install -y postgresql-16 postgresql-contrib-16
6666

67-
# Setup PostgreSQL configuration
68-
ENV PATH="$PATH:/usr/lib/postgresql/16/bin" PGDATA="/workspaces/.pgsql/data"
69-
RUN sudo mkdir -p $PGDATA \
70-
&& mkdir -p ~/.pg_ctl/bin ~/.pg_ctl/sockets \
71-
&& printf '#!/bin/bash\n[ ! -d $PGDATA ] && mkdir -p $PGDATA && initdb -D $PGDATA\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" start\n' > ~/.pg_ctl/bin/pg_start \
72-
&& printf '#!/bin/bash\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" stop\n' > ~/.pg_ctl/bin/pg_stop \
73-
&& chmod +x ~/.pg_ctl/bin/* \
74-
&& sudo addgroup dev \
75-
&& sudo adduser student dev \
76-
&& sudo chgrp -R dev $PGDATA \
77-
&& sudo chmod -R 775 $PGDATA \
78-
&& sudo setfacl -dR -m g:staff:rwx $PGDATA \
79-
&& sudo chmod 777 /var/run/postgresql \
80-
# This is a bit of a hack. At the moment we have no means of starting background
81-
# tasks from a Dockerfile. This workaround checks, on each bashrc eval, if the
82-
# PostgreSQL server is running, and if not starts it.
83-
&& printf "\n# Auto-start PostgreSQL server.\n[[ \$(pg_ctl status | grep PID) ]] || pg_start > /dev/null\n" >> ~/.bashrc
84-
ENV PATH="$PATH:$HOME/.pg_ctl/bin" PGHOSTADDR="127.0.0.1" PGDATABASE="postgres"
85-
86-
8767
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - \
8868
# Install Node.js and Yarn
8969
&& sudo apt-get install -y nodejs \
@@ -128,7 +108,6 @@ __git_complete g __git_main" >> ~/.bash_aliases \
128108
&& echo "alias grade='rake grade'" >> ~/.bash_aliases \
129109
&& echo "alias grade:reset_token='rake grade:reset_token'" >> ~/.bash_aliases \
130110
&& echo 'export PATH="$PWD/bin:$PATH"' >> ~/.bashrc \
131-
&& echo "nohup /workspaces/*/bin/postgres-monitor > /dev/null 2>&1 &" >> ~/.bashrc \
132111
&& echo "# Configure bundler and RVM paths" >> ~/.bashrc \
133112
&& echo 'export BUNDLE_PATH="/home/student/.bundle"' >> ~/.bashrc \
134113
&& echo 'export GEM_HOME="/home/student/.rvm/gems/ruby-3.4.1"' >> ~/.bashrc \

bin/server

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/bin/bash
22

3-
if pg_ctl status | grep -q 'no server running'; then
4-
pg_start;
5-
fi
6-
73
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
84
parentdir="$(dirname "$DIR")"
95
pid="$parentdir/tmp/pids/server.pid"

bin/setup

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ FileUtils.chdir APP_ROOT do
3333

3434
puts "\n== Checking for JavaScript tests and installing chromedriver if needed =="
3535
system! "bin/chromedriver_check"
36+
37+
puts "\n== Creating test database =="
38+
system! "bin/rails db:create RAILS_ENV=test"
39+
puts "\n== Initial setup complete =="
3640
end

config/database.yml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,17 @@ default: &default
2121

2222

2323
development:
24-
primary: &primary_development
25-
<<: *default
26-
database: rails_8_template_development
27-
cache:
28-
<<: *primary_development
29-
database: rails_8_template_development_cache
30-
migrations_paths: db/cache_migrate
31-
queue:
32-
<<: *primary_development
33-
database: rails_8_template_development_queue
34-
migrations_paths: db/queue_migrate
35-
cable:
36-
<<: *primary_development
37-
database: rails_8_template_development_cable
38-
migrations_paths: db/cable_migrate
24+
<<: *default
25+
url: <%= ENV.fetch("DATABASE_URL").gsub("?", "_development?") %>
3926

4027
# The specified database role being used to connect to PostgreSQL.
4128
# To create additional roles in PostgreSQL see `$ createuser --help`.
4229
# When left blank, PostgreSQL will use the default role. This is
4330
# the same name as the operating system user running Rails.
44-
#username: rails_8_template
31+
#username: student
4532

4633
# The password associated with the PostgreSQL role (username).
47-
#password:
34+
#password: postgres
4835

4936
# Connect on a TCP socket. Omitted by default since the client uses a
5037
# domain socket that doesn't need configuration. Windows does not have
@@ -69,7 +56,7 @@ development:
6956
# Do not set this db to the same as development or production.
7057
test:
7158
<<: *default
72-
database: rails_8_template_test
59+
url: <%= ENV.fetch("DATABASE_URL").gsub("?", "_test?") %>
7360

7461
# As with config/credentials.yml, you never want to store sensitive information,
7562
# like your database password, in your source code. If your source code is
@@ -98,13 +85,13 @@ production:
9885
encoding: utf8
9986
cache:
10087
<<: *primary_production
101-
database: rails_8_template_production_cache
88+
database: database_production_cache
10289
migrations_paths: db/cache_migrate
10390
queue:
10491
<<: *primary_production
105-
database: rails_8_template_production_queue
92+
database: database_production_queue
10693
migrations_paths: db/queue_migrate
10794
cable:
10895
<<: *primary_production
109-
database: rails_8_template_production_cable
96+
database: database_production_cable
11097
migrations_paths: db/cable_migrate

0 commit comments

Comments
 (0)