dockman 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +233 -0
- data/.gitlab-ci.yml +40 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +12 -0
- data/VERSION +1 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/dockman.gemspec +54 -0
- data/exe/dockman +9 -0
- data/lib/dockman/cli/entry.rb +32 -0
- data/lib/dockman/config.rb +5 -0
- data/lib/dockman/extensions/pathname.rb +21 -0
- data/lib/dockman/version.rb +3 -0
- data/lib/dockman.rb +18 -0
- data/lib/generators/dockman/dockify/setup/USAGE +12 -0
- data/lib/generators/dockman/dockify/setup/setup_generator.rb +29 -0
- data/lib/generators/dockman/dockify/setup/templates/.keep +0 -0
- data/lib/generators/dockman/dockify/skeleton/USAGE +15 -0
- data/lib/generators/dockman/dockify/skeleton/skeleton_generator.rb +45 -0
- data/lib/generators/dockman/dockify/skeleton/templates/.dockerignore +54 -0
- data/lib/generators/dockman/dockify/skeleton/templates/.keep +0 -0
- data/lib/generators/dockman/dockify/skeleton/templates/Dockerfile +48 -0
- data/lib/generators/dockman/dockify/skeleton/templates/config/database.yml +89 -0
- data/lib/generators/dockman/dockify/skeleton/templates/docker-compose.dbs.yml +71 -0
- data/lib/generators/dockman/dockify/skeleton/templates/docker-compose.yml +65 -0
- data/lib/generators/dockman/dockify/skeleton/templates/docker-sync.yml +7 -0
- data/lib/generators/dockman/dockify/skeleton/templates/envrc.erb +27 -0
- data/lib/generators/dockman/dockify/skeleton/templates/infra/scripts/create_db_user.sh +10 -0
- data/lib/generators/dockman/dockify/skeleton/templates/infra/scripts/init-user-db.sh +9 -0
- data/lib/generators/dockman/dockify/skeleton/templates/infra/scripts/start-dev.sh +22 -0
- data/lib/generators/dockman/dockify/skeleton/templates/infra/scripts/validate-migrated +7 -0
- data/lib/generators/dockman/dockify/skeleton/templates/infra/scripts/wait-for +79 -0
- data/lib/generators/dockman/dockify/skeleton/templates/infra/scripts/wait-for-it.sh +178 -0
- data/vendor/.keep +0 -0
- metadata +296 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Creates all the required files to dockerize this Rails project for Development
|
|
3
|
+
|
|
4
|
+
Example:
|
|
5
|
+
rails generate dockman:dockify:skeleton NAME
|
|
6
|
+
|
|
7
|
+
This will create:
|
|
8
|
+
- A `warehouse` folder
|
|
9
|
+
- An `infra` folder
|
|
10
|
+
- The `Dockerfile`
|
|
11
|
+
- `docker-compose` ymls for the main app and the database
|
|
12
|
+
- A `.dockerignore` file
|
|
13
|
+
- An `envrc` which holds the ENV vars
|
|
14
|
+
|
|
15
|
+
..and will append some entries to `.gitignore`
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'erb'
|
|
2
|
+
module Dockman
|
|
3
|
+
module Dockify
|
|
4
|
+
class SkeletonGenerator < Rails::Generators::NamedBase
|
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
6
|
+
|
|
7
|
+
def copy_warehouse
|
|
8
|
+
directory 'warehouse'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def copy_infra
|
|
12
|
+
directory 'infra'
|
|
13
|
+
if File.exist?('config/database.yml')
|
|
14
|
+
File.rename('config/database.yml',"config/database.#{Time.now.to_i}.yml")
|
|
15
|
+
end
|
|
16
|
+
copy_file 'config/database.yml'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def copy_docker_related
|
|
20
|
+
copy_file 'docker-compose.yml'
|
|
21
|
+
copy_file 'docker-compose.dbs.yml'
|
|
22
|
+
copy_file 'Dockerfile'
|
|
23
|
+
copy_file 'docker-sync.yml'
|
|
24
|
+
copy_file '.dockerignore'
|
|
25
|
+
template 'envrc.erb', '.env.development'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def ignore_responsibly
|
|
29
|
+
append_to_file '.gitignore' do <<-IGN
|
|
30
|
+
/warehouse/
|
|
31
|
+
/.docker-sync/
|
|
32
|
+
/.envrc
|
|
33
|
+
IGN
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def create_docker_volumes_and_networks
|
|
38
|
+
system "docker volume create #{file_name}-web-sync"
|
|
39
|
+
system "docker volume create #{file_name}-bundle-sync"
|
|
40
|
+
system "docker network create #{file_name}-nginx-proxy"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.git
|
|
2
|
+
.gitignore
|
|
3
|
+
README.md
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# OS X
|
|
7
|
+
#
|
|
8
|
+
.DS_Store
|
|
9
|
+
.AppleDouble
|
|
10
|
+
.LSOverride
|
|
11
|
+
# Icon must end with two \r
|
|
12
|
+
Icon
|
|
13
|
+
# Thumbnails
|
|
14
|
+
._*
|
|
15
|
+
# Files that might appear on external disk
|
|
16
|
+
.Spotlight-V100
|
|
17
|
+
.Trashes
|
|
18
|
+
# Directories potentially created on remote AFP share
|
|
19
|
+
.AppleDB
|
|
20
|
+
.AppleDesktop
|
|
21
|
+
Network Trash Folder
|
|
22
|
+
Temporary Items
|
|
23
|
+
.apdisk
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Rails
|
|
27
|
+
#
|
|
28
|
+
.env
|
|
29
|
+
.env.sample
|
|
30
|
+
*.rbc
|
|
31
|
+
capybara-*.html
|
|
32
|
+
log
|
|
33
|
+
tmp
|
|
34
|
+
db/*.sqlite3
|
|
35
|
+
db/*.sqlite3-journal
|
|
36
|
+
public/system
|
|
37
|
+
coverage/
|
|
38
|
+
spec/tmp
|
|
39
|
+
**.orig
|
|
40
|
+
|
|
41
|
+
.bundle
|
|
42
|
+
|
|
43
|
+
.ruby-version
|
|
44
|
+
.ruby-gemset
|
|
45
|
+
|
|
46
|
+
.rvmrc
|
|
47
|
+
|
|
48
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
|
49
|
+
vendor/assets/bower_components
|
|
50
|
+
*.bowerrc
|
|
51
|
+
bower.json
|
|
52
|
+
/warehouse/
|
|
53
|
+
/.docker-sync/
|
|
54
|
+
/.envrc
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
FROM ruby:2.5.1
|
|
2
|
+
RUN apt-get update && \
|
|
3
|
+
apt-get install --no-install-recommends -y \
|
|
4
|
+
build-essential \
|
|
5
|
+
git-core \
|
|
6
|
+
libxml2 \
|
|
7
|
+
libxml2-dev \
|
|
8
|
+
libxslt1-dev \
|
|
9
|
+
nodejs \
|
|
10
|
+
imagemagick \
|
|
11
|
+
libmagickcore-dev \
|
|
12
|
+
libmagickwand-dev \
|
|
13
|
+
libpq-dev \
|
|
14
|
+
inetutils-ping \
|
|
15
|
+
tzdata \
|
|
16
|
+
libpq-dev \
|
|
17
|
+
ca-certificates \
|
|
18
|
+
unzip \
|
|
19
|
+
# The entries below are used for capybara testing.
|
|
20
|
+
# Uncomment accordingly
|
|
21
|
+
# libicu-dev \
|
|
22
|
+
# qt5-default \
|
|
23
|
+
# libqt5webkit5-dev \
|
|
24
|
+
# gstreamer1.0-plugins-base \
|
|
25
|
+
# gstreamer1.0-tools \
|
|
26
|
+
# gstreamer1.0-x \
|
|
27
|
+
# xvfb \
|
|
28
|
+
# xauth \
|
|
29
|
+
# openjdk-8-jre \
|
|
30
|
+
wget --fix-missing && \
|
|
31
|
+
rm -rf /var/lib/apt/lists/*
|
|
32
|
+
|
|
33
|
+
RUN mkdir /app
|
|
34
|
+
RUN mkdir -p /root/.ssh/
|
|
35
|
+
|
|
36
|
+
WORKDIR /app
|
|
37
|
+
|
|
38
|
+
RUN ssh-keyscan -H github.com >> ~/.ssh/known_hosts
|
|
39
|
+
ENV GEM_HOME /bundle
|
|
40
|
+
ENV PATH $GEM_HOME/bin:$PATH
|
|
41
|
+
ENV BUNDLE_PATH /bundle
|
|
42
|
+
ENV BUNDLE_BIN /bundle/bin/
|
|
43
|
+
RUN gem install bundler && bundle config --global path "$GEM_HOME" && bundle config --global bin "$GEM_HOME/bin" && bundle config --global build.puma --with-opt-dir=/usr/local
|
|
44
|
+
RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.4.2-amd64.deb
|
|
45
|
+
RUN dpkg -i filebeat-6.4.2-amd64.deb
|
|
46
|
+
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && apt-get update && apt-get install -y postgresql-client-10 && rm -rf /var/lib/apt/lists/*
|
|
47
|
+
RUN gem install debase -v "0.2.3.beta2"
|
|
48
|
+
RUN gem install ruby-debug-ide -v "0.7.0.beta6"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# PostgreSQL. Versions 9.1 and up are supported.
|
|
2
|
+
#
|
|
3
|
+
# Install the pg driver:
|
|
4
|
+
# gem install pg
|
|
5
|
+
# On OS X with Homebrew:
|
|
6
|
+
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
|
|
7
|
+
# On OS X with MacPorts:
|
|
8
|
+
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
|
|
9
|
+
# On Windows:
|
|
10
|
+
# gem install pg
|
|
11
|
+
# Choose the win32 build.
|
|
12
|
+
# Install PostgreSQL and put its /bin directory on your path.
|
|
13
|
+
#
|
|
14
|
+
# Configure Using Gemfile
|
|
15
|
+
# gem 'pg'
|
|
16
|
+
#
|
|
17
|
+
default: &default
|
|
18
|
+
adapter: postgresql
|
|
19
|
+
encoding: unicode
|
|
20
|
+
# For details on connection pooling, see Rails configuration guide
|
|
21
|
+
# http://guides.rubyonrails.org/configuring.html#database-pooling
|
|
22
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
|
23
|
+
|
|
24
|
+
development:
|
|
25
|
+
<<: *default
|
|
26
|
+
database: <%= ENV.fetch("DB_NAME") %>_development
|
|
27
|
+
|
|
28
|
+
# The specified database role being used to connect to postgres.
|
|
29
|
+
# To create additional roles in postgres see `$ createuser --help`.
|
|
30
|
+
# When left blank, postgres will use the default role. This is
|
|
31
|
+
# the same name as the operating system user that initialized the database.
|
|
32
|
+
username: <%= ENV.fetch("DB_USER") %>
|
|
33
|
+
|
|
34
|
+
# The password associated with the postgres role (username).
|
|
35
|
+
password: <%= ENV.fetch("DB_PASS") %>
|
|
36
|
+
|
|
37
|
+
# Connect on a TCP socket. Omitted by default since the client uses a
|
|
38
|
+
# domain socket that doesn't need configuration. Windows does not have
|
|
39
|
+
# domain sockets, so uncomment these lines.
|
|
40
|
+
host: <%= ENV.fetch("DB_HOST") %>
|
|
41
|
+
|
|
42
|
+
# The TCP port the server listens on. Defaults to 5432.
|
|
43
|
+
# If your server runs on a different port number, change accordingly.
|
|
44
|
+
port: <%= ENV.fetch("DB_PORT") %>
|
|
45
|
+
|
|
46
|
+
# Schema search path. The server defaults to $user,public
|
|
47
|
+
#schema_search_path: myapp,sharedapp,public
|
|
48
|
+
|
|
49
|
+
# Minimum log levels, in increasing order:
|
|
50
|
+
# debug5, debug4, debug3, debug2, debug1,
|
|
51
|
+
# log, notice, warning, error, fatal, and panic
|
|
52
|
+
# Defaults to warning.
|
|
53
|
+
#min_messages: notice
|
|
54
|
+
|
|
55
|
+
# Warning: The database defined as "test" will be erased and
|
|
56
|
+
# re-generated from your development database when you run "rake".
|
|
57
|
+
# Do not set this db to the same as development or production.
|
|
58
|
+
test:
|
|
59
|
+
<<: *default
|
|
60
|
+
database: <%= ENV.fetch("DB_NAME") %>_test
|
|
61
|
+
username: <%= ENV.fetch("DB_USER") %>
|
|
62
|
+
password: <%= ENV.fetch("DB_PASS") %>
|
|
63
|
+
host: <%= ENV.fetch("DB_HOST") %>
|
|
64
|
+
port: <%= ENV.fetch("DB_PORT") %>
|
|
65
|
+
|
|
66
|
+
# As with config/secrets.yml, you never want to store sensitive information,
|
|
67
|
+
# like your database password, in your source code. If your source code is
|
|
68
|
+
# ever seen by anyone, they now have access to your database.
|
|
69
|
+
#
|
|
70
|
+
# Instead, provide the password as a unix environment variable when you boot
|
|
71
|
+
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
|
|
72
|
+
# for a full rundown on how to provide these environment variables in a
|
|
73
|
+
# production deployment.
|
|
74
|
+
#
|
|
75
|
+
# On Heroku and other platform providers, you may have a full connection URL
|
|
76
|
+
# available as an environment variable. For example:
|
|
77
|
+
#
|
|
78
|
+
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
|
|
79
|
+
#
|
|
80
|
+
# You can use this database configuration with:
|
|
81
|
+
#
|
|
82
|
+
# production:
|
|
83
|
+
# url: <%= ENV['DATABASE_URL'] %>
|
|
84
|
+
#
|
|
85
|
+
production:
|
|
86
|
+
<<: *default
|
|
87
|
+
database: <%= ENV.fetch("DB_NAME") %>_production
|
|
88
|
+
username: <%= ENV.fetch("DB_USER") %>
|
|
89
|
+
password: <%= ENV['DB_PASS'] %>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
version: '3.6'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
nginx:
|
|
5
|
+
image: jwilder/nginx-proxy
|
|
6
|
+
ports:
|
|
7
|
+
- "${PUMA_DEV_PORT}:80"
|
|
8
|
+
volumes:
|
|
9
|
+
- "/etc/nginx/conf.d"
|
|
10
|
+
- "/etc/nginx/vhost.d"
|
|
11
|
+
- "/usr/share/nginx/html"
|
|
12
|
+
- "/var/run/docker.sock:/tmp/docker.sock:ro"
|
|
13
|
+
environment:
|
|
14
|
+
- VIRTUAL_PROTO=http
|
|
15
|
+
networks:
|
|
16
|
+
- proxy-tier
|
|
17
|
+
|
|
18
|
+
postgres:
|
|
19
|
+
image: 'postgres:10.3-alpine'
|
|
20
|
+
volumes:
|
|
21
|
+
- './warehouse/pg/data:/var/lib/postgresql/data'
|
|
22
|
+
- './warehouse/pg-dumps:/root'
|
|
23
|
+
expose:
|
|
24
|
+
- ${DB_PORT}
|
|
25
|
+
environment:
|
|
26
|
+
- POSTGRES_USER=${PG_USER}
|
|
27
|
+
- POSTGRES_PASSWORD=${PG_PASSWORD}
|
|
28
|
+
# - POSTGRES_DB=template1
|
|
29
|
+
- VIRTUAL_PORT=${DB_PORT}
|
|
30
|
+
- VIRTUAL_HOST=pg.${COMPOSE_PROJECT_NAME}.test
|
|
31
|
+
networks:
|
|
32
|
+
- proxy-tier
|
|
33
|
+
|
|
34
|
+
pgadmin:
|
|
35
|
+
image: dpage/pgadmin4
|
|
36
|
+
expose:
|
|
37
|
+
- '80'
|
|
38
|
+
volumes:
|
|
39
|
+
- './warehouse/pgadmin:/var/lib/pgadmin'
|
|
40
|
+
environment:
|
|
41
|
+
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEF_EMAIL}
|
|
42
|
+
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEF_PASSWORD}
|
|
43
|
+
- VIRTUAL_HOST=pgadmin.${COMPOSE_PROJECT_NAME}.test
|
|
44
|
+
- VIRTUAL_PORT=80
|
|
45
|
+
# ports:
|
|
46
|
+
# - "7072:80"
|
|
47
|
+
networks:
|
|
48
|
+
- proxy-tier
|
|
49
|
+
|
|
50
|
+
hasura:
|
|
51
|
+
image: hasura/graphql-engine:v1.0.0-alpha28
|
|
52
|
+
expose:
|
|
53
|
+
- '8080'
|
|
54
|
+
# ports:
|
|
55
|
+
# - "8080:8080"
|
|
56
|
+
networks:
|
|
57
|
+
- proxy-tier
|
|
58
|
+
environment:
|
|
59
|
+
- HASURA_GRAPHQL_DATABASE_URL=postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}_development
|
|
60
|
+
- VIRTUAL_HOST=hasura.${COMPOSE_PROJECT_NAME}.test
|
|
61
|
+
- VIRTUAL_PORT=8080
|
|
62
|
+
- HASURA_GRAPHQL_ENABLE_CONSOLE=true
|
|
63
|
+
# volumes:
|
|
64
|
+
# - ./infra/scripts/wait-for:/root/wait-for
|
|
65
|
+
# command: sh -c '/root/wait-for ${DB_HOST}:${DB_PORT} -t 5 -- /bin/graphql-engine serve'
|
|
66
|
+
# depends_on:
|
|
67
|
+
# - ${DB_HOST}
|
|
68
|
+
networks:
|
|
69
|
+
proxy-tier:
|
|
70
|
+
external: true
|
|
71
|
+
name: "${COMPOSE_PROJECT_NAME}-nginx-proxy"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
version: '3.6'
|
|
2
|
+
services:
|
|
3
|
+
web:
|
|
4
|
+
build: .
|
|
5
|
+
command: infra/scripts/wait-for-it.sh ${DB_HOST}:${DB_PORT} -t 120 -- infra/scripts/start-dev.sh
|
|
6
|
+
volumes:
|
|
7
|
+
- "project-web-sync:/app:nocopy"
|
|
8
|
+
- "project-bundle-sync:/bundle:nocopy"
|
|
9
|
+
expose:
|
|
10
|
+
- "7000"
|
|
11
|
+
environment:
|
|
12
|
+
VIRTUAL_HOST: web.${COMPOSE_PROJECT_NAME}.test
|
|
13
|
+
VIRTUAL_PORT: 7000
|
|
14
|
+
DB_USER: ${DB_USER}
|
|
15
|
+
DB_PASS: ${DB_PASS}
|
|
16
|
+
DB_HOST: ${DB_HOST}
|
|
17
|
+
DB_NAME: ${DB_NAME}
|
|
18
|
+
DB_PORT: ${DB_PORT}
|
|
19
|
+
PG_USER: ${PG_USER}
|
|
20
|
+
PG_PASSWORD: ${PG_PASSWORD}
|
|
21
|
+
RAILS_ENV: development
|
|
22
|
+
# RAILS_LOG_TO_STDOUT: "true"
|
|
23
|
+
# DEBUG_MODE: "on"
|
|
24
|
+
ports:
|
|
25
|
+
- "26168"
|
|
26
|
+
- "1234:1234"
|
|
27
|
+
tty: true
|
|
28
|
+
stdin_open: true
|
|
29
|
+
networks:
|
|
30
|
+
- proxy-tier
|
|
31
|
+
|
|
32
|
+
guard:
|
|
33
|
+
build: .
|
|
34
|
+
command: bundle exec guard --no-bundler-warning --no-interactions
|
|
35
|
+
volumes:
|
|
36
|
+
- "project-bundle-sync:/bundle:nocopy"
|
|
37
|
+
- "project-web-sync:/app:nocopy"
|
|
38
|
+
environment:
|
|
39
|
+
VIRTUAL_HOST: web.${COMPOSE_PROJECT_NAME}.test
|
|
40
|
+
VIRTUAL_PORT: 7000
|
|
41
|
+
DB_USER: ${DB_USER}
|
|
42
|
+
DB_PASS: ${DB_PASS}
|
|
43
|
+
DB_HOST: ${DB_HOST}
|
|
44
|
+
DB_NAME: ${DB_NAME}
|
|
45
|
+
DB_PORT: ${DB_PORT}
|
|
46
|
+
PG_USER: ${PG_USER}
|
|
47
|
+
PG_PASSWORD: ${PG_PASSWORD}
|
|
48
|
+
RAILS_ENV: development
|
|
49
|
+
tty: true
|
|
50
|
+
stdin_open: true
|
|
51
|
+
networks:
|
|
52
|
+
- proxy-tier
|
|
53
|
+
|
|
54
|
+
volumes:
|
|
55
|
+
project-web-sync:
|
|
56
|
+
external: true
|
|
57
|
+
name: ${COMPOSE_PROJECT_NAME}-web-sync
|
|
58
|
+
project-bundle-sync:
|
|
59
|
+
external: true
|
|
60
|
+
name: ${COMPOSE_PROJECT_NAME}-bundle-sync
|
|
61
|
+
|
|
62
|
+
networks:
|
|
63
|
+
proxy-tier:
|
|
64
|
+
external: true
|
|
65
|
+
name: "${COMPOSE_PROJECT_NAME}-nginx-proxy"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
version: '2'
|
|
2
|
+
syncs:
|
|
3
|
+
${COMPOSE_PROJECT_NAME}-web-sync:
|
|
4
|
+
src: '.'
|
|
5
|
+
sync_excludes: ['.idea', '.sass-cache', 'sass', 'sass-cache', 'composer.json' , 'bower.json', 'package.json', 'Gruntfile*', 'bower_components', 'node_modules', '.gitignore', '.git', 'log','.envrc','.env.development', 'tmp/cache', 'tmp/storage','warehouse','vendor/bundle']
|
|
6
|
+
${COMPOSE_PROJECT_NAME}-bundle-sync:
|
|
7
|
+
src: './warehouse/bundle'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Those values will be used in the Rail's project database.yml
|
|
2
|
+
export DB_PASS="Passw0rd"
|
|
3
|
+
export DB_USER=<%= file_name %>_user
|
|
4
|
+
|
|
5
|
+
# This points to the name of the container; do not change unless you understand what this means
|
|
6
|
+
export DB_HOST=postgres
|
|
7
|
+
export DB_PORT=5432
|
|
8
|
+
export DB_NAME=<%= file_name %>
|
|
9
|
+
|
|
10
|
+
# You need to have a local development server like puma-dev (it will also work with pow, but it is deprecated, you have been warned)
|
|
11
|
+
export PUMA_DEV_PORT=24633
|
|
12
|
+
|
|
13
|
+
# This is the prefix of any container name that will be created via docker and docker-compose
|
|
14
|
+
# You need to make sure that this is unique among all your docker projects
|
|
15
|
+
# THIS IS IMPORTANT!
|
|
16
|
+
export COMPOSE_PROJECT_NAME=<%= file_name %>
|
|
17
|
+
|
|
18
|
+
# This is the Postgres admin user
|
|
19
|
+
export PG_USER=postgres
|
|
20
|
+
export PG_PASSWORD=postgres
|
|
21
|
+
export PG_MAINTENANCE_DB=template1
|
|
22
|
+
|
|
23
|
+
# Credentials for the pgadmin4 application
|
|
24
|
+
export PGADMIN_DEF_EMAIL=myemail@example.com
|
|
25
|
+
export PGADMIN_DEF_PASSWORD="Passw0rd"
|
|
26
|
+
|
|
27
|
+
# alias compdbs="COMPOSE_PROJECT_NAME=oss-dbs comp -f docker-compose.dbs.yml"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
PGPASSWORD="$PG_PASSWORD" psql -v ON_ERROR_STOP=1 --username "$PG_USER" -h "$DB_HOST" -c "CREATE USER $DB_USER PASSWORD '$DB_PASS' CREATEDB CREATEROLE INHERIT LOGIN;" &> /dev/null
|
|
4
|
+
|
|
5
|
+
#psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -d "$POSTGRES_DB" <<-EOSQL
|
|
6
|
+
# CREATE USER "$PG_USER" PASSWORD "$PG_PASSWORD" CREATEDB CREATEROLE INHERIT LOGIN;
|
|
7
|
+
# ALTER DATABASE "$DB_NAME" OWNER TO "$DB_USER";
|
|
8
|
+
#EOSQL
|
|
9
|
+
|
|
10
|
+
# The below has been removed from above
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -c "CREATE USER $DB_USER PASSWORD '$DB_PASS' CREATEDB CREATEROLE INHERIT LOGIN;" &> /dev/null
|
|
5
|
+
#<<-EOSQL
|
|
6
|
+
# CREATE USER docker;
|
|
7
|
+
# CREATE DATABASE docker;
|
|
8
|
+
# GRANT ALL PRIVILEGES ON DATABASE docker TO docker;
|
|
9
|
+
#EOSQL
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
bundle check || bundle install
|
|
4
|
+
|
|
5
|
+
#until PGPASSWORD=nopass psql -h "db" -U "myamsix_returns" -d "myamsix_abstract" -c '\q'; do
|
|
6
|
+
# >&2 echo "Postgres is unavailable - sleeping"
|
|
7
|
+
# sleep 1
|
|
8
|
+
#done
|
|
9
|
+
#
|
|
10
|
+
#>&2 echo "Postgres is up - executing command"
|
|
11
|
+
|
|
12
|
+
if bin/rails db:migrate:status &> /dev/null; then
|
|
13
|
+
bin/rails db:migrate
|
|
14
|
+
else
|
|
15
|
+
bin/rails db:setup
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
if [ -z "${DEBUG_MODE}" ]; then
|
|
19
|
+
rm -rf tmp/pids/* && bundle exec rails server --port 7000 --binding 0.0.0.0 -e development
|
|
20
|
+
else
|
|
21
|
+
rm -rf tmp/pids/* && bundle exec rdebug-ide --key-value --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --host 0.0.0.0 --port 1234 --dispatcher-port 26168 -- bin/rails server -b 0.0.0.0 -p 7000 -e development
|
|
22
|
+
fi
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
TIMEOUT=15
|
|
4
|
+
QUIET=0
|
|
5
|
+
|
|
6
|
+
echoerr() {
|
|
7
|
+
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
usage() {
|
|
11
|
+
exitcode="$1"
|
|
12
|
+
cat << USAGE >&2
|
|
13
|
+
Usage:
|
|
14
|
+
$cmdname host:port [-t timeout] [-- command args]
|
|
15
|
+
-q | --quiet Do not output any status messages
|
|
16
|
+
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
|
|
17
|
+
-- COMMAND ARGS Execute command with args after the test finishes
|
|
18
|
+
USAGE
|
|
19
|
+
exit "$exitcode"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
wait_for() {
|
|
23
|
+
for i in `seq $TIMEOUT` ; do
|
|
24
|
+
nc -z "$HOST" "$PORT" > /dev/null 2>&1
|
|
25
|
+
|
|
26
|
+
result=$?
|
|
27
|
+
if [ $result -eq 0 ] ; then
|
|
28
|
+
if [ $# -gt 0 ] ; then
|
|
29
|
+
exec "$@"
|
|
30
|
+
fi
|
|
31
|
+
exit 0
|
|
32
|
+
fi
|
|
33
|
+
sleep 1
|
|
34
|
+
done
|
|
35
|
+
echo "Operation timed out" >&2
|
|
36
|
+
exit 1
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
while [ $# -gt 0 ]
|
|
40
|
+
do
|
|
41
|
+
case "$1" in
|
|
42
|
+
*:* )
|
|
43
|
+
HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
|
|
44
|
+
PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
|
|
45
|
+
shift 1
|
|
46
|
+
;;
|
|
47
|
+
-q | --quiet)
|
|
48
|
+
QUIET=1
|
|
49
|
+
shift 1
|
|
50
|
+
;;
|
|
51
|
+
-t)
|
|
52
|
+
TIMEOUT="$2"
|
|
53
|
+
if [ "$TIMEOUT" = "" ]; then break; fi
|
|
54
|
+
shift 2
|
|
55
|
+
;;
|
|
56
|
+
--timeout=*)
|
|
57
|
+
TIMEOUT="${1#*=}"
|
|
58
|
+
shift 1
|
|
59
|
+
;;
|
|
60
|
+
--)
|
|
61
|
+
shift
|
|
62
|
+
break
|
|
63
|
+
;;
|
|
64
|
+
--help)
|
|
65
|
+
usage 0
|
|
66
|
+
;;
|
|
67
|
+
*)
|
|
68
|
+
echoerr "Unknown argument: $1"
|
|
69
|
+
usage 1
|
|
70
|
+
;;
|
|
71
|
+
esac
|
|
72
|
+
done
|
|
73
|
+
|
|
74
|
+
if [ "$HOST" = "" -o "$PORT" = "" ]; then
|
|
75
|
+
echoerr "Error: you need to provide a host and port to test."
|
|
76
|
+
usage 2
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
wait_for "$@"
|