Skip to content

Commit 7e81b3b

Browse files
committed
Update dev env stuff
1 parent 10400cc commit 7e81b3b

30 files changed

+113
-126
lines changed

bin/address

-7
This file was deleted.

bin/admin/ban-user

-3
This file was deleted.

bin/bower

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm --entrypoint bower client $@
3+
docker compose run --rm --entrypoint bower web $@

bin/build

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
docker-compose build
3+
docker compose build
44
# Only create the database on development.
5-
# Schema and seed are bone by bin/seed
6-
docker-compose run --rm server rake db:create
7-
docker-compose run --rm server rake db:setup RAILS_ENV=test
5+
# Schema and seed are done by bin/seed
6+
docker compose run --rm api rake db:create
7+
docker compose run --rm api rake db:setup RAILS_ENV=test

bin/bundle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm --entrypoint ./bin/bundle server $@
3+
docker compose run --rm --entrypoint ./bin/bundle api $@

bin/clean-uploads

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm --entrypoint rm server -rf "/opt/kitsu/server/public/system/*"
3+
docker compose run --rm --entrypoint rm api -rf "/opt/kitsu/server/public/system/*"

bin/ember

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm client $@
3+
docker compose run --rm web $@

bin/guard

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm -e "RAILS_ENV=test" server guard $@
3+
docker compose run --rm -e "RAILS_ENV=test" api guard $@

bin/logs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

3-
containers="${@:-server client sidekiq}"
3+
containers="${@:-api web worker}"
44

5-
docker-compose logs $containers
5+
docker compose logs $containers

bin/npm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm --entrypoint npm client $@
3+
docker compose run --rm --entrypoint npm web $@

bin/open-browser

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cd "$(dirname "$0")/../"
44

5-
url="http://$(./bin/address):$(./bin/port)/"
5+
url="http://kitsu.localhost:$(./bin/port)/"
66

77
# Most common means of opening browsers on most systems. We don't need 100%
88
# success rate, just Good Enough™.

bin/pg_dump

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm postgres sh -c "PGPASSWORD=\$POSTGRES_PASSWORD pg_dump --username=\$POSTGRES_USER --host=postgres $@"
3+
docker compose run --rm postgres sh -c "pg_dump --username=kitsu_development --host=postgres $@"

bin/port

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose port router 80 | cut -d: -f2
3+
docker compose port router 80 | cut -d: -f2

bin/psql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm postgres sh -c "PGPASSWORD=\$POSTGRES_PASSWORD psql --username=\$POSTGRES_USER --host=postgres $@"
3+
docker compose run --rm postgres sh -c "psql --username=kitsu_development --host=postgres $@"

bin/rails

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm --entrypoint ./bin/rails server $@
3+
docker compose run --rm --entrypoint ./bin/rails api $@

bin/rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm server rake $@
3+
docker compose run --rm api rake $@

bin/rebuild

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cd "$(dirname "$0")/../"
44

55
./bin/check_for_updates
66

7-
docker-compose stop $@
8-
docker-compose rm -f $@
9-
docker-compose build $@
10-
docker-compose up -d $@
7+
docker compose stop $@
8+
docker compose rm -f $@
9+
docker compose build $@
10+
docker compose up -d $@

bin/redis-cli

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm redis redis-cli -h redis -n 1 "$@"
3+
docker compose run --rm redis redis-cli -h redis -n 1 "$@"

bin/rspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose run --rm -e "RAILS_ENV=test" --entrypoint ./bin/rspec server $@
3+
docker compose run --rm -e "RAILS_ENV=test" --entrypoint ./bin/rspec api $@

bin/start

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cd "$(dirname "$0")/../"
44

5-
docker-compose up -d $@
5+
docker compose up -d $@
66

7-
echo "Listening at http://$(./bin/address):$(./bin/port)/"
7+
echo "Listening at http://localhost:$(./bin/port)/"
88
echo "Logs are available via \`bin/logs\`"

bin/status

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose ps
3+
docker compose ps

bin/stop

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker-compose stop $@
3+
docker compose stop $@

bin/testem

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ function stop_listening {
1919

2020
trap stop_listening EXIT
2121

22-
docker-compose run --rm --publish=7357:7357 client test --server
22+
docker compose run --rm --publish=7357:7357 client test --server

bin/yarn

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker compose run --rm --entrypoint yarn client $@

docker-compose.yml

+27-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: "3.8"
22

33
volumes:
44
postgres:
@@ -9,65 +9,64 @@ volumes:
99
driver: local
1010

1111
services:
12-
# Database servers
12+
# Databases
1313
postgres:
14-
image: postgres:9.4
14+
image: postgres:11
1515
environment:
1616
PGDATA: /var/lib/postgresql/data/pgdata
17-
POSTGRES_PASSWORD: mysecretpassword
18-
POSTGRES_USER: postgres
17+
POSTGRES_USER: kitsu_development
18+
POSTGRES_HOST_AUTH_METHOD: trust
1919
volumes:
2020
- postgres:/var/lib/postgresql/data
21-
ports: ['5432:5432']
21+
ports: [5432]
2222
redis:
2323
image: redis
2424
elasticsearch:
2525
image: elasticsearch:2
2626

27-
# Mailcatcher
27+
# Pretend cloud services
2828
mailcatcher:
2929
image: schickling/mailcatcher
30-
ports: [1080]
30+
minio:
31+
image: minio/minio:latest
32+
command: [server, "/data"]
33+
volumes:
34+
- ./uploads:/data
3135

3236
# Web server, routing /api and / to server, client respectively
3337
router:
3438
build: ./router
35-
links: [client, server]
39+
depends_on: [web, api, minio, mailcatcher]
3640
volumes:
3741
- uploads:/srv/www/uploads/system
38-
ports: [80]
42+
ports: ["42069:80"]
3943

40-
# Rails server
41-
server: &rails
42-
links: [postgres, redis, elasticsearch, mailcatcher]
43-
build: ./server
44+
# Application
45+
api: &rails
46+
depends_on: [postgres, redis, elasticsearch, mailcatcher, minio]
47+
build:
48+
context: ./server
49+
dockerfile: Dockerfile.local
4450
volumes:
4551
- ./server:/opt/kitsu/server
4652
- uploads:/opt/kitsu/server/public/system
4753
# Cache bundle
4854
- /usr/local/bundle
4955
environment:
50-
DATABASE_URL: 'postgresql://postgres:mysecretpassword@postgres/'
51-
REDIS_URL: 'redis://redis/1'
56+
DATABASE_URL: "postgresql://kitsu_development@postgres/"
57+
ELASTICSEARCH_URL: "elasticsearch:9200"
58+
REDIS_URL: "redis://redis/1"
5259
RAILS_ENV: development
53-
SMTP_ADDRESS: 'mailcatcher'
54-
SMTP_PORT: '1025'
55-
56-
# Sidekiq
57-
sidekiq:
60+
SMTP_ADDRESS: "mailcatcher"
61+
SMTP_PORT: "1025"
62+
worker:
5863
<<: *rails
5964
command: [sidekiq]
60-
61-
# Ember server
62-
client:
65+
web:
6366
build: ./client
6467
volumes:
6568
- ./client:/opt/kitsu/client
66-
- /root/.cache/yarn
67-
- /opt/kitsu/client/node_modules
68-
- /opt/kitsu/client/bower_components
6969
tmpfs:
7070
- /opt/kitsu/client/tmp
7171
environment:
7272
EMBER_ENV: development
73-
ports: ['57777:57777']

router/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ MAINTAINER Kitsu, Inc.
33

44
RUN rm /etc/nginx/conf.d/default.conf
55
COPY ./nginx.conf /etc/nginx/conf.d/kitsu.conf
6+
COPY ./*.include.conf /etc/nginx/

router/logging.include.conf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Extreme Logging
2+
error_log stderr debug;
3+
rewrite_log on;
4+
log_subrequest on;

router/nginx.conf

+42-59
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,44 @@
1+
# The $upstream nonsense is to force runtime (instead of boot-time) DNS resolution so that
2+
# Docker containers can be swapped without restarting nginx
13
server {
2-
listen 80;
3-
4-
# Extreme Logging
5-
error_log stderr debug;
6-
rewrite_log on;
7-
log_subrequest on;
8-
9-
# Proxy settings
10-
resolver 127.0.0.11;
11-
proxy_redirect off;
12-
proxy_set_header Host $http_host;
13-
proxy_set_header X-Real_IP $remote_addr;
14-
proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
15-
proxy_set_header X-Forwarded-Proto $scheme;
16-
17-
# File serving
18-
sendfile on;
19-
include /etc/nginx/mime.types;
20-
21-
# This nonsense is to force runtime (instead of boot-time) resolution of DNS
22-
# so that Docker containers can be swapped, while being functionally
23-
# equivalent to the following block:
24-
#
25-
# location /api/ {
26-
# proxy_pass http://server/;
27-
# }
28-
#
29-
# It rewrites the path, stripping the prefix of the location block, so that
30-
# Rails doesn't have to be completely aware that it's nested under /api/.
31-
location ~* /api/(?<path>.*$) {
32-
set $upstream "http://server/api/";
33-
proxy_pass $upstream$path$is_args$args;
34-
}
35-
location ~* /api/system/(?<path>.*$) {
36-
set $upstream "http://server/";
37-
proxy_pass $upstream$path$is_args$args;
38-
client_max_body_size 10M;
39-
}
40-
location ~* /rails/(?<path>.*$) {
41-
set $upstream "http://server/rails/";
42-
proxy_pass $upstream$path$is_args$args;
43-
}
44-
location ~* /forest(?<path>.*$) {
45-
set $upstream "http://server/api/forest/";
46-
proxy_pass $upstream$path$is_args$args;
47-
}
48-
location ~* /(?<path>.*$) {
49-
set $upstream "http://client/";
50-
proxy_pass $upstream$path$is_args$args;
51-
}
52-
location ^~ /system/ {
53-
root /srv/www/uploads/;
54-
try_files $uri @media;
55-
}
56-
location @media {
57-
rewrite ^/system(/.*)$ $1 break;
58-
proxy_set_header Host 'media.kitsu.io';
59-
proxy_pass https://media.kitsu.io;
60-
}
4+
listen 80 default_server;
5+
server_name kitsu.localhost;
6+
7+
include proxy.include.conf;
8+
include logging.include.conf;
9+
10+
location /api/ {
11+
set $upstream "http://api";
12+
proxy_pass $upstream;
13+
}
14+
location / {
15+
set $upstream "http://web";
16+
proxy_pass $upstream;
17+
}
18+
}
19+
20+
server {
21+
listen 80;
22+
server_name media.kitsu.localhost;
23+
24+
include proxy.include.conf;
25+
include logging.include.conf;
26+
27+
location / {
28+
set $upstream "http://minio:9000";
29+
proxy_pass $upstream;
30+
}
31+
}
32+
33+
server {
34+
listen 80;
35+
server_name mail.kitsu.localhost;
36+
37+
include proxy.include.conf;
38+
include logging.include.conf;
39+
40+
location / {
41+
set $upstream "http://mailcatcher:1080";
42+
proxy_pass $upstream;
43+
}
6144
}

router/proxy.include.conf

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Proxy settings
2+
resolver 127.0.0.11;
3+
proxy_redirect off;
4+
proxy_set_header Host $http_host;
5+
proxy_set_header X-Real_IP $remote_addr;
6+
proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
7+
proxy_set_header X-Forwarded-Proto $scheme;

uploads/kitsu-ugc-dev/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)