Browse Source

Docker complete!

pull/1/head
Stephen 10 months ago
parent
commit
da9f2c71b7
10 changed files with 119 additions and 4 deletions
  1. +29
    -0
      Dockerfile
  2. +1
    -0
      Gemfile
  3. +18
    -0
      README.md
  4. +3
    -2
      config/database.yml
  5. +2
    -2
      config/pressr.yml
  6. +20
    -0
      docker-compose.yml
  7. +11
    -0
      dockerstart.sh
  8. +20
    -0
      util/createAdmin.rb
  9. +1
    -0
      util/createAdmin.sh
  10. +14
    -0
      webapp.conf

+ 29
- 0
Dockerfile View File

@@ -0,0 +1,29 @@
FROM phusion/passenger-ruby26

#Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update -qq && \
apt-get install -y build-essential libpq-dev sudo tzdata yarn imagemagick


RUN bash -lc 'rvm install ruby-2.6.4'
RUN bash -lc 'rvm --default use ruby-2.6.4'
RUN gem install bundler
RUN sudo -u app mkdir /home/app/pressr
COPY Gemfile Gemfile.lock /home/app/pressr/
WORKDIR /home/app/pressr
ENV RAILS_ENV production
RUN sudo -u app bundle install --deployment
COPY --chown=app:app . /home/app/pressr/

ADD dockerstart.sh /dockerstart.sh

RUN rm -f /etc/service/nginx/down
RUN rm /etc/nginx/sites-enabled/default
ADD webapp.conf /etc/nginx/sites-enabled/webapp.conf

CMD ["/dockerstart.sh"]

EXPOSE 3000

+ 1
- 0
Gemfile View File

@@ -52,6 +52,7 @@ end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'irb'

gem 'jquery-rails'


+ 18
- 0
README.md View File

@@ -26,6 +26,24 @@ Database settings are configured in config/database.yml. It defaults to Postgres

Custom settings are configured in config/pressr.yml.

## Deployment (Docker)

A sample docker-compose.yml is provided. Make sure to change the `SECRET_KEY_BASE` ! This is very important!

0. Run docker-compose once

`docker-compose up`

1. Terminate the process and create an admin account

`docker-compose run web bash -c 'util/createAdmin.sh'`

2. Start docker compose again

`docker-compose up`

You will be able to access Pressr at http://localhost:3000

## Deployment (Debian 10)

0. Ensure system is up to date


+ 3
- 2
config/database.yml View File

@@ -81,5 +81,6 @@ test:
production:
<<: *default
database: Pressure_production
username: Pressure
password: <%= ENV['PRESSURE_DATABASE_PASSWORD'] %>
username: <%= ENV['DB_USER'] %>
password: <%= ENV['DB_PASS'] %>
host: <%= ENV['DB_HOST'] %>

+ 2
- 2
config/pressr.yml View File

@@ -2,9 +2,9 @@ default: &default
#When this is set, site runs in single-blog mode
#Instead of the front page being a combination of all blogs,
#It will only be the blog id set below
main_blog_id: null
main_blog_id: <%= ENV['MAIN_BLOG'] %>
#If false, only allows admins to create blogs
allow_user_blogs: true
allow_user_blogs: <%= ENV['ALLOW_USER_BLOGS'] || true %>

development:
<<: *default


+ 20
- 0
docker-compose.yml View File

@@ -0,0 +1,20 @@
version: '3'
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
web:
build: .
volumes:
- ./docker_uploads:/home/app/pressr/public/uploads
ports:
- "3000:3000"
depends_on:
- db
environment:
- DB_USER=postgres
- DB_HOST=db
- SECRET_KEY_BASE=pleasechangeme
#- MAIN_BLOG=1
#- ALLOW_USER_BLOGS=false

+ 11
- 0
dockerstart.sh View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e

cd /home/app/pressr/

#chown -R app:app /home/app/pressr/public/uploads #necessary?
su app - -c "bundle exec rake assets:precompile"
#create DB if DNE
su app - -c "bundle exec rake db:create"
su app - -c "bundle exec rake db:migrate"
/sbin/my_init

+ 20
- 0
util/createAdmin.rb View File

@@ -0,0 +1,20 @@
puts "==== Pressr Admin Creation Script ===="
print "Username: "
uname = gets.chomp
print "Password: "
upass = gets.chomp
print "Email: "
uemail = gets.chomp
print "Display name: "
udname = gets.chomp

u = User.new(username: uname, display_name: udname, password: upass, email: uemail, role: 1)

if u.save
puts("Success!")
else
puts("Error(s):")
u.errors.full_messages.each do |x|
puts x
end
end

+ 1
- 0
util/createAdmin.sh View File

@@ -0,0 +1 @@
bundle exec rails runner util/createAdmin.rb

+ 14
- 0
webapp.conf View File

@@ -0,0 +1,14 @@
server {
listen 3000;
server_name _ default_server;

client_max_body_size 100M;
root /home/app/pressr/public;

passenger_enabled on;
passenger_user app;
passenger_min_instances 1;
passenger_ruby /usr/bin/ruby;
}

passenger_pre_start http://localhost:3000/;

Loading…
Cancel
Save