Skip to content

Commit

Permalink
Working on deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
delonnewman committed Aug 14, 2023
1 parent ad732e8 commit c50c000
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 2,613 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# Ignore git directory.
/.git/

.idea/
.github/

# Ignore bundler config.
/.bundle

# Ignore all default key files.
/config/master.key
# /config/master.key
/config/credentials/*.key

# Ignore all environment files.
Expand Down
17 changes: 6 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz
# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems and node modules
# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libpq-dev node-gyp pkg-config python-is-python3

# Install yarn
ARG YARN_VERSION=1.22.19
RUN npm install -g yarn@$YARN_VERSION
apt-get install --no-install-recommends -y build-essential git libpq-dev

# Build options
ENV PATH="/usr/local/node/bin:$PATH"
Expand All @@ -47,10 +43,6 @@ ENV PATH="/usr/local/node/bin:$PATH"
COPY Gemfile Gemfile.lock .
RUN bundle install

# Install node modules
COPY package.json yarn.lock .
RUN yarn install --frozen-lockfile

# Copy application code
COPY . .

Expand All @@ -67,7 +59,10 @@ RUN apt-get update -qq && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Run and own the application files as a non-root user for security
RUN useradd rails
ARG UID=1000 \
GID=1000
RUN groupadd -f -g $GID rails && \
useradd -u $UID -g $GID rails
USER rails:rails

# Copy built artifacts: gems, application
Expand Down
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ gem 'memo_wise'
gem 'rails-pattern_matching'
gem 'interactor'

# NLP
# Data
gem 'faker'
gem 'sentimental'

# TODO: Move to Dart Sass
Expand Down Expand Up @@ -100,8 +101,6 @@ group :development, :test do
gem 'rubocop-performance', require: false

gem 'simplecov', require: false

gem 'faker'
end

group :development do
Expand Down
7 changes: 5 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative "config/application"
require 'bundler/audit/task'

Bundler::Audit::Task.new
if Rails.env.development?
require 'bundler/audit/task'
Bundler::Audit::Task.new
end

Rails.application.load_tasks
3 changes: 2 additions & 1 deletion app/assets/javascripts/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"watch": "shadow-cljs watch submitter editor test",
"browser-repl": "shadow-cljs browser-repl",
"submitter-repl": "shadow-cljs cljs-repl submitter",
"editor-repl": "shadow-cljs cljs-repl editor"
"editor-repl": "shadow-cljs cljs-repl editor",
"build": "shadow-cljs release editor submitter"
},
"devDependencies": {
"shadow-cljs": "2.19.1",
Expand Down
2 changes: 1 addition & 1 deletion config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Dyt5sWlxTT9bZp/f4rOxOezOUzp+wlEI8I18byvPGDOkXIuFYbi7v9POG/vTcBQuZYUg/yfObx991pM8x76ojMkMgQOjGej263BSuQH4PQ75lEZAtR9Q8RHgO8w1Vp2gXOA7uS453sSeO9E9MolF1ic3dgJReNQHCO7bhshiWVtqDDBe4yW3RaVaalgtnCV3pIFGbidg6DvxPP3nkKFmnXsISPyl1NNETY2AGnBsY1i6pjUkYeEihkTtRLcnNOPwPWv9KTJaCarzAqe2aX9ODm5+6eD8XjZiLQPW1sP76QAnDI8AkgMoNB++IYvfKX2JMiVC48dr+dXLb+RRVJqGNbIz4TpBkgceBzWxSMM7UJvzGF/rnMfpyrugE5PhxqBJmd5iJIV9roSDChHHuooZzkelIKt2CvbN22v6--xfVGt6KPBux1aQg7--1M/kkxCkA/kBm3F5W6sm0g==
gmWoTanSJExZbU6z3FqhJ024ZwBUAdy0YXMWU4PMnGMv1OTKR0NwQYONB6ctEI1vJ1Rd/mAMYtIeCYJTSAE4IQ/b1Q7TsVeLmgZg9X1HxR+JAln2wZht+o58aLDCD6t+ZYisaSRDmVg+RlnI7KePP0FVmLFR4mOqOGLZZtAaZMf7LfUsZI378Wb4n3QKBuK7L5ifmanJ7J4tq8vR0K4+FkSGvH7v5A9JgNkOjxCKNQEFrEqAsQMprL82bgvoNOATdtllGOlEXyaagV8OhzRsKdSYUOx3qs0he1RwKkjZkXm/OgEDZN2g/qPY9RBHeYZqJYCpeSRYZ804lqTzUCLSRYA7Ixot6EFKoIUwMwIwZuzcO327BNrI1YrbQ8I69hToYMaXBba2AAguz+plnMMghxXIbgzfM4MPkDSk--txWOlQaNVR/umd+o--+KXJ58m3iNqL0Ogse+vRKw==
4 changes: 1 addition & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,4 @@ test:
#
production:
<<: *default
database: dragnet_production
username: dragnet
password: <%= ENV["DRAGNET_DATABASE_PASSWORD"] %>
url: <%= ENV["DRAGNET_DATABASE_URL"] %>
4 changes: 2 additions & 2 deletions config/dockerfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ options:
bin-cd: false
cache: false
ci: false
compose: false
compose: true
fullstaq: false
jemalloc: true
jemalloc: false
label: {}
mysql: false
nginx: false
Expand Down
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: "3.8"
services:
web:
build:
context: .
args:
UID: ${UID:-1000}
GID: ${GID:-${UID:-1000}}
ports:
- "3000:3000"
environment:
- RAILS_MASTER_KEY=$RAILS_MASTER_KEY
- DRAGNET_DATABASE_URL=postgres://dragnet:dragnetroot@postgres-db:5433/dragnet
depends_on:
postgres-db:
condition: service_healthy

postgres-db:
image: postgres
environment:
POSTGRES_USER: dragnet
POSTGRES_PASSWORD: dragnetroot
POSTGRES_DB: dragnet
volumes:
- ./tmp/db:/var/lib/postgresql/data
ports:
- "5433:5432"
healthcheck:
test: pg_isready
interval: 2s
timeout: 5s
retries: 30
6 changes: 6 additions & 0 deletions lib/tasks/docker.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace :docker do
desc 'build docker image'
task :image do
sh "docker build -t dragnet ."
end
end
16 changes: 13 additions & 3 deletions lib/tasks/frontend.rake
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# frozen_string_literal: true

EDITOR_SOURCE_PATH = 'app/assets/javascripts/frontend'
FRONTEND_SOURCE_PATH = 'app/assets/javascripts/frontend'

namespace :frontend do
desc 'start dev server for frontend'
task :server do
sh "cd #{EDITOR_SOURCE_PATH} && npm run watch"
sh "cd #{FRONTEND_SOURCE_PATH} && npm run watch"
end

desc 'install frontend dependencies'
task :deps do
sh "npm install #{EDITOR_SOURCE_PATH}"
sh "npm install #{FRONTEND_SOURCE_PATH}"
end

desc 'build frontend for production'
task build: :clean do
sh "cd #{FRONTEND_SOURCE_PATH} && npm run build"
end

desc 'remove frontend code'
task :clean do
sh "rm -rf public/js/editor && rm -rf public/js/submitter"
end
end
Loading

0 comments on commit c50c000

Please sign in to comment.