Skip to content

Commit a8e7e59

Browse files
committed
completed docker configuration for production
1 parent 95e3fca commit a8e7e59

File tree

19 files changed

+1008
-845
lines changed

19 files changed

+1008
-845
lines changed

.dockerignore

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
.bin
33
.env
44
.env.production
5+
.env*
6+
!.env.example
57
.git/
68
.gitignore
79
.github/
@@ -12,10 +14,19 @@
1214
log/*
1315
tmp/*
1416
node_modules/
15-
public/packs
17+
public/packs/
18+
public/assets/
1619
yarn-error.log
1720
coverage/
1821
test/
1922
spec/
2023
config/master.key
21-
config/initializers/secret_token.rb
24+
config/initializers/secret_token.rb
25+
config/credentials/development.key
26+
config/credentials/production.key
27+
docker-compose.override.yml
28+
yarn-debug.log*
29+
.yarn-integrity
30+
.yarn/
31+
docker-compose.yml
32+
vendor/bundle

.env.example

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
export RAILS_ENV=production
3+
export NODE_ENV=production
4+
5+
# TODO: Generate a secret
6+
# 1. generate `rails secret`
7+
# 2. add to the env variables SECRET_KEY_BASE and RAILS_MASTER_KEY
8+
# 3. run `rails credentials:edit --environment production` and enter the secret under `secret_key_base`
9+
# export SECRET_KEY_BASE=<SECRET KEY>
10+
# export RAILS_MASTER_KEY=<SECRET KEY>
11+
12+
# TODO: choose one restart policy
13+
# export DOCKER_RESTART_POLICY=unless-stopped
14+
# export DOCKER_RESTART_POLICY=always
15+
16+
# TODO: Assign a no-reply email address
17+
# This is the email that automated emails, password resets, and confirmations will come from
18+
# export NO_REPLY_EMAIL=<NO REPLY EMAIL>
19+
20+
# TODO: Assign a contact email
21+
# A contact email for users if they have questions or encounter issues
22+
# export CONTACT_EMAIL=<NO REPLY EMAIL>
23+
24+
# TODO: Add smtp email info
25+
# export SMTP_HOST=<SMTP HOST>
26+
# export SMTP_PORT=<SMTP PORT>
27+
# openssl verify mode defaults to "none" if nothing provided
28+
# export SMTP_OPENSSL_VERIFY_MODE=<SMTP OPENSSL VERIFY MODE>
29+
30+
# TODO: Complete default url options
31+
# export PRODUCTION_HOST=<PRODUCTION HOST>
32+
# export PRODUCTION_PROTOCOL=<PRODUCTION PROTOCOL>
33+
34+
# TODO: Add postgres user and password
35+
# export POSTGRES_USER=<POSTGRES USER>
36+
# export POSTGRES_PASSWORD=<POSTGRES PASSWORD>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ config/initializers/secret_token.rb
4545
/yarn-error.log
4646
yarn-debug.log*
4747
.yarn-integrity
48+
.yarn/
4849

4950
# .env
5051
.env

Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM ruby:3.0.3-slim
2+
WORKDIR /app
3+
RUN apt-get update -qq \
4+
&& apt-get install -y --no-install-recommends build-essential curl git vim libpq-dev \
5+
&& curl -sSL https://deb.nodesource.com/setup_14.x | bash - \
6+
&& curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
7+
&& echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list \
8+
&& apt-get update && apt-get install -y --no-install-recommends nodejs yarn postgresql-client \
9+
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
10+
&& apt-get clean \
11+
&& useradd --create-home forecasts \
12+
&& chown forecasts:forecasts -R /app
13+
14+
COPY entrypoint.sh /usr/bin/
15+
RUN chmod +x /usr/bin/entrypoint.sh
16+
17+
USER forecasts
18+
ENV BUNDLER_VERSION 2.2.32
19+
COPY --chown=forecasts:forecasts Gemfile Gemfile.lock ./
20+
21+
RUN bundle config set --local deployment 'true' \
22+
&& bundle config set --local without 'development test' \
23+
&& bundle install \
24+
&& rm -rf vendor/bundle/ruby/3.0.0/cache/*.gem \
25+
&& find vendor/bundle/ruby/3.0.0/gems/ -name "*.c" -delete \
26+
&& find vendor/bundle/ruby/3.0.0/gems/ -name "*.o" -delete
27+
28+
COPY --chown=forecasts:forecasts package.json yarn.lock ./
29+
RUN yarn install --frozen-lockfile --non-interactive --production
30+
31+
COPY --chown=forecasts:forecasts . .
32+
RUN rm entrypoint.sh
33+
34+
ENV PATH="${PATH}:/app/bin"
35+
36+
ENTRYPOINT ["entrypoint.sh"]
37+
EXPOSE 3000
38+
39+
# precompile production app
40+
RUN RAILS_ENV=production SECRET_KEY_BASE=`rails secret` rails assets:precompile --trace \
41+
&& yarn cache clean \
42+
&& rm -rf tmp/cache vendor/assets test spec node_modules
43+
44+
# Configure the main process to run when running the image
45+
CMD ["rails", "server", "-b", "0.0.0.0"]

Dockerfile.production

Lines changed: 0 additions & 17 deletions
This file was deleted.

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
ruby '3.0.2'
4+
ruby '3.0.3'
55

66
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
77
gem 'rails', '~> 6.1.4'

Gemfile.lock

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ GEM
7070
bcrypt (3.1.16)
7171
benchmark (0.1.1)
7272
bindex (0.8.1)
73-
bootsnap (1.7.7)
73+
bootsnap (1.9.3)
7474
msgpack (~> 1.0)
7575
brakeman (5.1.1)
7676
builder (3.2.4)
@@ -146,7 +146,9 @@ GEM
146146
minitest (5.14.4)
147147
msgpack (1.4.2)
148148
nio4r (2.5.8)
149-
nokogiri (1.12.3-x86_64-darwin)
149+
nokogiri (1.12.5-x86_64-darwin)
150+
racc (~> 1.4)
151+
nokogiri (1.12.5-x86_64-linux)
150152
racc (~> 1.4)
151153
orm_adapter (0.5.0)
152154
paper_trail (12.0.0)
@@ -159,7 +161,7 @@ GEM
159161
public_suffix (4.0.6)
160162
puma (5.4.0)
161163
nio4r (~> 2.0)
162-
racc (1.5.2)
164+
racc (1.6.0)
163165
rack (2.2.3)
164166
rack-mini-profiler (2.3.2)
165167
rack (>= 1.2.0)
@@ -321,6 +323,7 @@ GEM
321323

322324
PLATFORMS
323325
x86_64-darwin-19
326+
x86_64-linux
324327

325328
DEPENDENCIES
326329
annotate (~> 3.1.1)
@@ -361,7 +364,7 @@ DEPENDENCIES
361364
yard (~> 0.9.26)
362365

363366
RUBY VERSION
364-
ruby 3.0.2p107
367+
ruby 3.0.3p157
365368

366369
BUNDLED WITH
367-
2.2.22
370+
2.2.32

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22

33
This application provides an interface for companies and businesses to track hours for specific contracts.
44

5+
## Running in production
6+
1. Copy the `.env.example` file and rename it to `.env`
7+
2. Fill in all the appropriate and applicable environment variables (ensure following all of the "TODO" instructions)
8+
59
## Technical Details
610
`fields` are shared across teams, but `team_fields` are used to track which fields a team uses at a particular time.

app/views/forecast_mailer/confirmation_email.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@
6262
month: @team_monthly_forecast.monthly_forecast.date.strftime("%B"),
6363
member_id: @member.id
6464
)%>. Only your most recent submssion will be used.
65-
</p>
65+
</p>
66+
<p>If you have any questions or issues, please contact <%= Rails.application.config.contact_email %></p>

app/views/reminders/reminder_mailer/reminder.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
)
1414
%>
1515
</p>
16+
<p>If you have any questions or issues, please contact <%= Rails.application.config.contact_email %></p>
1617

0 commit comments

Comments
 (0)