Skip to content

Commit

Permalink
feat(docker): Added basic development image for docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbl committed Oct 5, 2018
1 parent 6590925 commit 9829b49
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'
services:
serpico:
environment:
- SRP_ADMIN=administrator
- SRP_FINDINGS=yes
build:
dockerfile: docker/dev.dockerfile
context: .
ports:
- "8443:8443"
volumes:
- ./:/Serpico
9 changes: 9 additions & 0 deletions docker/dev.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ruby:2.3.5
MAINTAINER Serpico
ENV SRP_ROOT /Serpico
WORKDIR $SRP_ROOT
# No volume: It will be mounted by docker-compose.
COPY Gemfile $SRP_ROOT/
RUN bundle install
EXPOSE 8443
CMD ["bash", "docker/docker.sh"]
12 changes: 12 additions & 0 deletions docker/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/bash
# This script is used as the entry point for the docker image.
# It will initialize the database if it isn't already present.

if [ ! -f "$SRP_ROOT/db/master.db" ]; then
echo "First run detected. Initializing database..."
ruby "$SRP_ROOT/scripts/first_time.rb"
fi

# CMD ["ruby", "serpico.rb"]
ruby serpico.rb

10 changes: 10 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ path to the database on the host [must be absolute][1].

[1]: https://docs.docker.com/engine/reference/run/#volume-shared-filesystems

## docker-compose

The `docker-compose.yml` in the repository is aimed at development use. It will
provision the ruby environment inside the container and mount the repository as
the docker application, allowing for reloading the source code by simply
restarting the container. The dockerfile `docker/dev.dockerfile` is used by
compose.

## Caveats

This is a work in progress, so a few things are currently not supported.
Expand All @@ -52,4 +60,6 @@ This is a work in progress, so a few things are currently not supported.
`first_time.rb` will not run, and there won't be any certificates for SSL.
- `config.json` is not exposed to the host so customization requires rebuilding
the image or accessing it with `docker exec bash`.
- `docker-compose up` will not automatically reload the backend when `.rb`
files are changed. This is a possible improvement.

0 comments on commit 9829b49

Please sign in to comment.