-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.git/ | ||
Dockerfile | ||
docker-compose.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM ruby:latest | ||
|
||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs file imagemagick git && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN adduser --disabled-password --gecos "FRAB" --uid 1000 frab | ||
|
||
COPY . /home/frab/app | ||
RUN chown -R frab:frab /home/frab/app | ||
|
||
USER frab | ||
|
||
WORKDIR /home/frab/app | ||
|
||
RUN bundle install | ||
|
||
COPY docker-cmd.sh /home/frab/app/docker-cmd.sh | ||
|
||
RUN cp config/database.yml.template config/database.yml | ||
|
||
VOLUME /home/frab/app/public | ||
|
||
EXPOSE 3000 | ||
|
||
ENV RACK_ENV=production \ | ||
SECRET_KEY_BASE=asdkjf3245jsjfakjq435jadsgjlkq4j5jwj45jasdjvlj \ | ||
FRAB_HOST=localhost \ | ||
FRAB_PROTOCOL=http \ | ||
RAILS_SERVE_STATIC_FILES=true \ | ||
CAP_USER=frab \ | ||
FROM_EMAIL=frab@localhost \ | ||
SMTP_ADDRESS=172.17.0.1 \ | ||
SMTP_PORT=25 \ | ||
SMTP_NOTLS=true \ | ||
DATABASE_URL=sqlite3://localhost/home/frab/data/database.db | ||
|
||
CMD ["/home/frab/app/docker-cmd.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Docker Setup | ||
|
||
Frab can also be run inside a Docker container. Basic familiarity with docker is assumed in this guide. | ||
|
||
In addition to a `Dockerfile` a basic `docker-compose.yml` file is also provided. | ||
|
||
## Building the Docker Image | ||
|
||
|
||
``` | ||
docker-compose build | ||
``` | ||
|
||
or | ||
|
||
``` | ||
docker build -t frab/frab . | ||
``` | ||
|
||
|
||
## Configuration | ||
|
||
The `Dockerfile` sets some basic default environment variables for frab to use including a sqlite3 database. However you should tune them to your own needs. This can be done by editing the `docker-compose.yml` file or passing the environment variables to the `docker run` command with the `-e` flag. | ||
|
||
At a minimum you should change the default `SECRET_KEY_BASE` variable. | ||
|
||
### Database Configuration | ||
|
||
The default setup uses a sqlite3 database located in `/home/frab/data`. If you want it to persist across container restarts you should add a docker volume to that directory. Alternatively you can pass a `DATABASE_URL` environment variable to use another database like postgresql or mysql. | ||
|
||
The example docker-compose file used another postgres container as a database. | ||
|
||
# Running | ||
|
||
To run frab with docker-compose after building just run: | ||
|
||
``` | ||
docker-compose up | ||
``` | ||
|
||
The initial admin username and password will be printed to stdout on first run. | ||
|
||
|
||
To start the containers as a service run: | ||
|
||
``` | ||
docker-compose up -d | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "> Prepping '${RACK_ENV}' mode" | ||
if [ $RACK_ENV == "production" ] | ||
then | ||
echo "> assets:precompile" | ||
rake assets:precompile | ||
|
||
if [ ! "$(rails db:version)" == "Current version: 0" ] | ||
then | ||
echo "> DB Migrate" | ||
rails db:migrate | ||
else | ||
echo "> Setting up new db" | ||
rails db:setup | ||
fi | ||
elif [ $RACK_ENV == "development" ] | ||
then | ||
echo "> bin/setup" | ||
./bin/setup | ||
fi | ||
|
||
echo "> Starting server" | ||
rails server -b 0.0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
version: '2' | ||
|
||
services: | ||
frab: | ||
image: frab/frab | ||
build: . | ||
container_name: frab_app | ||
volumes: | ||
- data:/home/frab/app/public | ||
ports: | ||
- 3000:3000 | ||
networks: | ||
- backend | ||
environment: | ||
- TZ=America/Los_Angeles | ||
- SECRET_KEY_BASE=5fe64927bda359b186be52191c1ce3e5ef34827a | ||
- DATABASE_URL=postgresql://frab:HWsJ54XvCOXyeSZhAQi9@db/frab | ||
- FRAB_CURRENCY_UNIT='$$' | ||
- FROM_EMAIL=frab@localhost | ||
restart: always | ||
depends_on: | ||
- db | ||
|
||
db: | ||
image: postgres:9.5 | ||
container_name: frab_db | ||
restart: always | ||
volumes: | ||
- db_data:/var/lib/postgresql/data | ||
networks: | ||
- backend | ||
environment: | ||
- TZ=America/Los_Angeles | ||
- POSTGRES_USER=frab | ||
- POSTGRES_PASSWORD=HWsJ54XvCOXyeSZhAQi9 | ||
- POSTGRES_DB=frab | ||
|
||
networks: | ||
backend: | ||
|
||
volumes: | ||
data: {} | ||
db_data: {} | ||
|