This repository has been archived by the owner on May 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
75 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,14 @@ | ||
FROM ruby:2.3.5 | ||
MAINTAINER Serpico | ||
|
||
ENV SRP_ROOT /Serpico | ||
WORKDIR $SRP_ROOT | ||
COPY . $SRP_ROOT | ||
|
||
RUN bundle install | ||
|
||
# Allow DB to be on a shared volume | ||
VOLUME ["$SRP_ROOT/db"] | ||
EXPOSE 8443 | ||
|
||
CMD ["bash", "scripts/docker.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,49 @@ | ||
# Running Inside Docker | ||
|
||
The included `Dockerfile` allows to run Serpico inside docker from any system | ||
that supports containers. | ||
|
||
By default, Serpico listens on 8443, you can expose it as `443` if you would | ||
like by using `docker run -p 443:8443 ...` | ||
|
||
The image needs to first be built. | ||
|
||
1. Build the image | ||
2. Map the database location in docker-compose or at `docker run` time. | ||
3. If the database doesn't exist, it will be created with defaults | ||
|
||
## Creating the image | ||
|
||
This will create a container with the current state of your repository. | ||
The database is not created at this point, and this image is safe for | ||
distribution. | ||
|
||
``` | ||
docker build -t serpico . | ||
``` | ||
|
||
The Dockerfile exposes a `VOLUME` at `/Serpico/db` to allow mounting an | ||
external database through `docker-compose` or `docker run -v`. | ||
|
||
|
||
## Running with `docker run` | ||
|
||
``` | ||
# In the foreground | ||
docker run --rm -p 8443 -v"$(pwd)":/Serpico/db -it serpico | ||
``` | ||
|
||
This will store the database locally at `$PWD/master.db` Please note that the | ||
path to the database on the host [must be absolute][1]. | ||
|
||
[1]: https://docs.docker.com/engine/reference/run/#volume-shared-filesystems | ||
|
||
## Caveats | ||
|
||
This is a work in progress, so a few things are currently not supported. | ||
|
||
- Running a new container with an existing `master.db` will not work because | ||
`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`. | ||
|
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,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 | ||
|