diff --git a/Dockerfile b/Dockerfile
index 5f10b70..09f3b43 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,13 +1,15 @@
FROM ruby:2.6.3-alpine
+ARG RAILS_MASTER_KEY=''
+ENV RAILS_MASTER_KEY ${RAILS_MASTER_KEY}
+
+ENV RAILS_ENV production
ENV APP_PATH /usr/src/app
ENV BUNDLE_VERSION 2.1.4
-ENV RAILS_LOG_TO_STDOUT true
-ENV RAILS_ENV production
WORKDIR $APP_PATH
-EXPOSE $RAILS_PORT
+EXPOSE 3000
ENV ALPINE_MIRROR "http://dl-cdn.alpinelinux.org/alpine"
RUN echo "${ALPINE_MIRROR}/v3.11/main/" >> /etc/apk/repositories
@@ -30,17 +32,15 @@ RUN gem install bundler --version "$BUNDLE_VERSION"
COPY ./Gemfile .
COPY ./Gemfile.lock .
-RUN bundle install --jobs 20 --retry 5
+RUN bundle install --binstubs
COPY ./package.json .
COPY ./yarn.lock .
-RUN yarn
+RUN yarn --production
COPY . .
-RUN chmod 600 config/master.key
-
RUN bundle exec rails assets:precompile
-CMD ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"]
\ No newline at end of file
+CMD ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"]
diff --git a/Gemfile b/Gemfile
index c5080e4..4ef554e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -23,7 +23,7 @@ gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
-gem 'redis', '~> 4.0'
+# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
diff --git a/Gemfile.lock b/Gemfile.lock
index b3a100b..a6ca7a3 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -152,7 +152,6 @@ GEM
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
- redis (4.3.1)
regexp_parser (2.1.1)
rexml (3.2.5)
rubocop (1.17.0)
@@ -250,7 +249,6 @@ DEPENDENCIES
pg (>= 0.18, < 2.0)
puma (~> 4.3.8)
rails (~> 5.2.6)
- redis (~> 4.0)
rubocop (~> 1.17)
rubocop-rails
selenium-webdriver
@@ -268,4 +266,4 @@ RUBY VERSION
ruby 2.6.3p62
BUNDLED WITH
- 2.1.4
+ 2.1.4 2.1.4
diff --git a/README.md b/README.md
index 1ed84ab..4dfee8e 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,27 @@
# URL shortener
-## How to run
+
+
+
-### Development
+# Features
+- [x] Create link model (make sure to create a index for the slug and click counter)
+- [x] Generate unique slug
+- [x] Link unit tests
+- [x] Stimulus setup
+- [x] Link controller (handle redirection)
+- [x] Main page with input box
+- [x] Create user model
+- [x] User unit tests
+- [x] Add userId key to link model
+- [x] Login and logout (sessions)
+- [x] User links view
+- [x] Modals layout
+- [x] Deployment CI
+
+# How to run
+
+## Development
- Run migrations
```bash
docker-compose up -d db
@@ -13,19 +32,19 @@ docker-compose run --rm app bundle exec rails db:migrate
docker-compose up
```
-### Testing
+## Testing
```bash
docker-compose run --rm app bundle exec rails test
```
-### Rubocop
+## Rubocop
```bash
docker-compose run --rm app bundle exec rubocop
```
-## Results
+# Results
-- Testing
+## Testing
```bash
Finished in 2.211344s, 9.9487 runs/s, 10.4009 assertions/s.
22 runs, 23 assertions, 0 failures, 0 errors, 0 skips
@@ -48,7 +67,7 @@ BRANCH COVERAGE: 100.00% -- 20/20 branches in 8 branches
+----------+-------------------------------------------+-------+--------+---------+-----------------+----------+-----------------+------------------+
```
-- Rubocop
+## Rubocop
```bash
Inspecting 43 files
...........................................
@@ -56,21 +75,11 @@ Inspecting 43 files
43 files inspected, no offenses detected
```
-- Production link
-https://s-shortener.herokuapp.com/
+- Dokku deployment
+```bash
+ bundle exec rails assets:precompile
+ bundle exec rails db:migrate
+```
-## TODO
-- [x] Create link model (make sure to create a index for the slug and click counter)
-- [x] Generate unique slug
-- [x] Link unit tests
-- [x] Stimulus setup
-- [x] Link controller (handle redirection)
-- [x] Main page with input box
-- [x] Create user model
-- [x] User unit tests
-- [x] Add userId key to link model
-- [x] Login and logout (sessions)
-- [x] User links view
-- [x] Modals layout
-- [x] Setup Redis for production cache_store
-- [x] Deployment CI
\ No newline at end of file
+- Production link
+https://url-shortener.sjdonado.de
diff --git a/config/cable.yml b/config/cable.yml
index 06e2b24..1b9f7a4 100644
--- a/config/cable.yml
+++ b/config/cable.yml
@@ -5,6 +5,4 @@ test:
adapter: async
production:
- adapter: redis
- url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
- channel_prefix: app_production
+ adapter: async
diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc
index f594f71..e9632bf 100644
--- a/config/credentials.yml.enc
+++ b/config/credentials.yml.enc
@@ -1 +1 @@
-ixtsTt2O/bqumywSaldHxkihLw2+zumFOL1B0NtK6lQ460IU6WZsnEFc02muVzP5t4Rn3zyZjaP74fZEgxqfRELE8pffCZTHCkaPeaeULgqwQJy9OVAkd0SHN0k8jRlFtNFKQvrzE7ngnbO+eX9ZwlotQlaUxAlSrOJ9av7OaRwCfMpMgjVbKZfxJvhFW0l+twV8hjdyXbuFuoS8g3VrsaEYvZOu+zz0QMwgK5WmOIQbvwn/VSWWHkRraPGPm+xpUyi8UmAVFjdT02zSEaaauaRhtSSNGz5ufYEPZMrs99iKw/HFpkUHs+R0tqafFT2CBw7ai+h9i/ZblYppJDw5PpnoqY/kneBsz2NT+a0eyL7ZS9YJit+M77Z40gULUapc03SzRlAXy3rrkVFGqIaHSKibOKfpn/KbL9D+--2hixMh1aBR3PcnjL--Tzv9NyC3MTTMHYHn8u5Lhw==
\ No newline at end of file
+Wk6KXgfCMEdFwrlXhheO89gYdFLEemFYnWBHSKZ7rw73RRoHvVypao5sjPXsKEBG8yOfS2wHMf13VMcfWhGHX9ZJrm+Dav/QRz3cNkaJ2RLmgBDp0vjGpYQ4bQxJSHILYxFD6paiyrS89VsfM5yTl+Zmhhg1Kjc2DFeY6KClLAT+84rWkd+BoTb4VSLcP0RYLStvITr4G66SEDN3pUdoOgcHqCHDYsNZPhSQjkSOHftCjcHziIgHZmhboj6gMNk7R6mVhNc5mhhg68WuhXOR2UCdebxAGDKAtRjqSGWv0A6kwMO1yFQDRdYnURjKJCQxNACqd8XNh5hLuLvpeV04E6SivbF7uIapwtQdjL3Tq1+mSaGeYqduPpSSFiizINJa459Q6qxc2gev/pgPvY8vdwB/iMQznUj3he6Q--aLOyL+GzKtf/En3Q--pI05hACTxEqi2bHlVD6QGg==
\ No newline at end of file
diff --git a/config/environments/production.rb b/config/environments/production.rb
index c728e83..bd63ae5 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -18,7 +18,7 @@ Rails.application.configure do
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
- # config.require_master_key = true
+ config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
@@ -58,7 +58,7 @@ Rails.application.configure do
# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
- config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'] }
+ config.cache_store = :memory_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
diff --git a/config/webpacker.yml b/config/webpacker.yml
index 0c98236..64aede6 100644
--- a/config/webpacker.yml
+++ b/config/webpacker.yml
@@ -83,7 +83,7 @@ production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
- compile: false
+ compile: true
# Extract and emit a css file
extract_css: true
diff --git a/entrypoint.sh b/entrypoint.sh
index 830085b..233b993 100644
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -2,6 +2,6 @@
set -e
-rm -f $APP_PATH/tmp/pids/server.pid
+rm -f "$APP_PATH/tmp/pids/server.pid"
-${@}
\ No newline at end of file
+"${@}"