Skip to content

Commit

Permalink
Initial commit in dockerized repo
Browse files Browse the repository at this point in the history
  • Loading branch information
alepbloyd committed Aug 19, 2024
1 parent 756f217 commit 3686396
Show file tree
Hide file tree
Showing 193 changed files with 262 additions and 153 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generate rails credentials
# Run `rails credentials:help` for instructions

RAILS_MASTER_KEY=
POSTGRES_PASSWORD=
9 changes: 0 additions & 9 deletions .gitattributes

This file was deleted.

83 changes: 61 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,81 @@
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

.env
!.env.example

# -- Rails --

# Ignore bundler config.
/.bundle
/rails/.bundle

# Ignore all environment files (except templates).
/.env*
!/.env*.erb
/rails/.env
!/rails/.env*.erb

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
/rails/log/*
/rails/tmp/*
!/rails/log/.keep
!/rails/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep
/rails/tmp/pids/*
!/rails/tmp/pids/
!/rails/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/
!/tmp/storage/.keep
/rails/storage/*
/rails!/storage/.keep
/rails/tmp/storage/*
/rails!/tmp/storage/
/rails!/tmp/storage/.keep

# Ignore master key for decrypting credentials and more.
/config/master.key

# Ignore local vscode settings
.vscode
/rails/config/credentials.yml.enc
/rails/config/master.key

# Ignore application configuration
/config/application.yml
/rails/config/application.yml

/rails/coverage/*

/rails/node_modules

/coverage/*
# -- React --
/react/dist

/node_modules
# Logs
/react/logs
/react/*.log
/react/npm-debug.log*
/react/yarn-debug.log*
/react/yarn-error.log*
/react/pnpm-debug.log*
/react/lerna-debug.log*

/react/node_modules
/react/dist
/react/dist-ssr
/react/*.local

# Editor directories and files
/react/.vscode/*
/react/!.vscode/extensions.json
/react/.idea
/react/.DS_Store
/react/*.suo
/react/*.ntvs*
/react/*.njsproj
/react/*.sln
/react/*.sw?


# -- NGINX --
/nginx/certs/*
!/nginx/certs/.keep

# Ignore local settings

.vscode
.DS_Store
7 changes: 7 additions & 0 deletions MIT-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright <YEAR> <COPYRIGHT HOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84 changes: 0 additions & 84 deletions config/database.yml

This file was deleted.

86 changes: 86 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
services:
db:
image: postgres:latest
env_file: .env
container_name: bookworm-postgres
volumes:
- postgres_data:/var/lib/postgresql/data
command: "postgres -c 'max_connections=500'"
environment:
POSTGRES_DB: bookworm_production
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
healthcheck:
test: ["CMD-SHELL", "pg_isready -d bookworm_production -U postgres"]
interval: 30s
timeout: 5s
retries: 10
rails:
build: ./rails
container_name: bookworm-rails
command: "bundle exec rails s -p 3001 -b '0.0.0.0'"
env_file: .env
environment:
RAILS_MASTER_KEY: $RAILS_MASTER_KEY
DB_HOST: db
DB_NAME: bookworm_production
DB_USERNAME: bookworm
DB_PASSWORD: $POSTGRES_PASSWORD
RAILS_ENV: production
healthcheck:
test: ["CMD-SHELL", "curl -d 'query{investigations {id name}}' -X POST http://localhost:3001/graphql || exit 1"]
interval: 30s
timeout: 5s
retries: 5
ports:
- 3001:3001
volumes:
- ./rails:/rails
depends_on:
db:
condition:
service_healthy
react:
build: ./react
container_name: bookworm-react
env_file: .env
environment:
NODE_ENV: production
volumes:
- ./react:/react
ports:
- 3000:3000
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --spider --tries=1 localhost:3000 || exit 1"]
interval: 30s
timeout: 5s
retries: 10
depends_on:
db:
condition:
service_healthy
rails:
condition:
service_healthy
nginx:
image: "nginx:latest"
container_name: "bookworm-nginx"
ports:
- 443:443
- 80:80
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/certs:/etc/ssl
restart: unless-stopped
depends_on:
rails:
condition:
service_healthy
react:
condition:
service_healthy

volumes:
postgres_data: {}
networks:
default:
name: bookworm
13 changes: 0 additions & 13 deletions lib/faker/archival.rb

This file was deleted.

File renamed without changes.
28 changes: 28 additions & 0 deletions nginx/conf.d/bookworm-ssl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
server {
listen 443;
server_name bookworm;

ssl_certificate /etc/ssl/certificate.pem;
ssl_certificate_key /etc/ssl/key.pem;

location / {
proxy_pass https://bookworm-react:3000;
proxy_redirect default;
proxy_http_version 1.1;

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_max_temp_file_size 0;

#this is the maximum upload size
client_max_body_size 10m;
client_body_buffer_size 128k;

proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_request_buffering off; # Required for HTTP CLI commands
}
}
25 changes: 25 additions & 0 deletions nginx/conf.d/bookworm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 80;
server_name bookworm;

location / {
proxy_pass http://bookworm-react:3000;
proxy_redirect default;
proxy_http_version 1.1;

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_max_temp_file_size 0;

#this is the maximum upload size
client_max_body_size 10m;
client_body_buffer_size 128k;

proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_request_buffering off; # Required for HTTP CLI commands
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3686396

Please sign in to comment.