-
Notifications
You must be signed in to change notification settings - Fork 8
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
17 changed files
with
414 additions
and
133 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 |
---|---|---|
@@ -1,3 +1,29 @@ | ||
FROM tomcat:alpine | ||
COPY target/smeagol-*-standalone.war $CATALINA_HOME/webapps/smeagol.war | ||
FROM alpine:3.6 | ||
|
||
MAINTAINER Simon Brooke <[email protected]> | ||
|
||
ENV JAVA_HOME=/usr/lib/jvm/default-jvm | ||
|
||
RUN apk add --no-cache openjdk8 && \ | ||
ln -sf "${JAVA_HOME}/bin/"* "/usr/bin/" | ||
|
||
# ensure the directories I'm going to write to actually exist! | ||
RUN mkdir -p /usr/local/bin | ||
RUN mkdir -p /usr/local/etc | ||
|
||
COPY target/smeagol-*-standalone.jar /usr/local/bin/smeagol.jar | ||
COPY resources/passwd /usr/local/etc/passwd | ||
COPY resources/config.edn /usr/local/etc/config.edn | ||
COPY resources/public/content /usr/local/etc/content | ||
|
||
ENV SMEAGOL_CONFIG=/usr/local/etc/config.edn | ||
ENV SMEAGOL_CONTENT_DIR=/usr/local/etc/content | ||
ENV SMEAGOL_PASSWD=/usr/local/etc/passwd | ||
ENV TIMBRE_DEFAULT_STACKTRACE_FONTS="{}" | ||
ENV TIMBRE_LEVEL=':info' | ||
ENV PORT=80 | ||
|
||
EXPOSE 80 | ||
|
||
CMD java -jar /usr/local/bin/smeagol.jar | ||
|
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
{:admin {:admin true, :email "[email protected]", :password "admin"}, :jenny {:email "[email protected]", :admin false, :password "$s0$f0801$1uniQfftB37G5e5GklJANQ==$kQ0+/YcCuaz2x5iYjwhNlDlnWX/exE/8pSC+R4C0WvQ="}} | ||
{:admin {:admin true, :email "[email protected]", :password "admin"}, :simon {:email "[email protected]", :admin true, :password "$s0$f0801$sqhbxtzK6nx9RnVUhwtQlg==$dMIUbof8esjsGyiB+zb3gMH21L/WSCR+wD3vIag4EVc="}} |
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
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
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,55 @@ | ||
Smeagol is available as a Docker image | ||
|
||
To run my Docker image, use | ||
|
||
docker run -p 127.0.0.1:80:80 simonbrooke/smeagol | ||
Where 127.0.0.1 is the IP address through which you want to forward port 80 (in real life it wouldn't be 127.0.0.1, but that's safe for testing). | ||
|
||
You can then browse to Smeagol by pointing your browser at http://localhost/. | ||
|
||
As of version 0.99.10, the Docker image is now based on the Jetty, rather than the Tomcat, deployment of Smeagol (that is to say, it runs the executable jar file). This makes for a lighter weight Docker image. All configuration can be overridden with [[Environment Variables]], which can be passed into the Docker container when the image is invoked, or from a [[Configuration]] file. | ||
|
||
The `config.edn` and `passwd` files and the `content` directory are copied into `/usr/local/etc` in the Docker image, and the appropriate environment variables are set up to point to them: | ||
``` | ||
COPY resources/passwd /usr/local/etc/passwd | ||
COPY resources/config.edn /usr/local/etc/config.edn | ||
COPY resources/public/content /usr/local/etc/content | ||
ENV SMEAGOL_CONFIG=/usr/local/etc/config.edn | ||
ENV SMEAGOL_CONTENT_DIR=/usr/local/etc/content | ||
ENV SMEAGOL_PASSWD=/usr/local/etc/passwd | ||
``` | ||
This works for play purposes. However, it means that any edits made to either the `passwd` file or the `content` directory will be lost when the Docker image is shut down. You really need to have these resources copied to a place in a real file system which is mounted by the image. While I intend that by the 1.1.0 release of Smeagol it will be possible to configure a remote origin repository to which changes are periodically pushed, which will backup and preserve the content, this won't save the `passwd` file, as this is deliberately not stored in the git repository for security reasons. | ||
|
||
## Mounting real file systems | ||
|
||
It's possible to mount external file systems, and to override environment variables, with arguments to Docker's extraordinarily complex [run command](https://docs.docker.com/engine/reference/commandline/run/). | ||
|
||
I'm currently working with a recipe: | ||
|
||
docker run -p 127.0.0.1:80:80 -v ~/tmp/etc:/usr/local/etc simonbrooke/smeagol | ||
|
||
Where: | ||
|
||
1. `127.0.0.1` is the IP address on the real host on which you wish to serve; | ||
2. `:80:80` maps port 80 on the image to port 80 on the specified IP address; | ||
3. `~/tmp/etc` is the directory on the file system of the real host where files are stored; | ||
4. `/usr/local/etc` is the directory within the image file system to which that will be mounted; | ||
|
||
This works, and uses the default values of the environment variables which are set up in the Docker image. However, I'm very much prepared to believe there are better recipes. | ||
|
||
## Status | ||
|
||
This image is _experimental_, but it does seem to work fairly well. What it does **not** yet do, however, is push the git repository to a remote location, so when you tear the Docker image down your edits will be lost. My next objective for this image is for it to have a cammand line parameter being the git address of a repository from which it can initialise the Wiki content, and to which it will periodically push local changes to the Wiki content. | ||
|
||
## Building the Docker image | ||
|
||
To build your own Docker image, run: | ||
|
||
lein clean | ||
lein bower install | ||
lein ring uberjar | ||
lein docker build | ||
|
||
This will build a new Docker image locally; you can, obviously, push it to your own Docker repository if you wish. |
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,23 @@ | ||
## Smeagol-specific environment variables | ||
Smeagol can be configured entirely with environment variables. The variables are: | ||
|
||
1. `SMEAGOL_CONFIG` (optional but advised) should be the full or relative pathname of a Smeagol [[Configuration]] file; | ||
2. `SMEAGOL_CONTENT_DIR` should be the full or relative pathname of the directory from which Smeagol should serve content (which may initially be empty, but must be writable by the process which runs Smeagol); | ||
3. `SMEAGOL_DEFAULT_LOCALE` which should be a locale specification in the form "en-GB", "fr-FR", or whatever to suit your users; | ||
4. `SMEAGOL_FORMATTERS` should be an [edn](https://github.com/edn-format/edn)-formatted map of formatter directives (this would be pretty hard to do from an environment variable); | ||
5. `SMEAGOL_LOG_LEVEL` which should be one of `TRACE DEBUG INFO WARN ERROR FATAL` | ||
6. `SMEAGOL_PASSWD` should be the full or relative pathname of a Smeagol Passwd file - see [[Security and authentication]]. This file must contain an entry for at least your initial user, and, if you want to administer users through the user interface, must be writable by the process which runs Smeagol. | ||
7. `SMEAGOL_SITE_TITLE` which should be the title you want shown on the header of all pages. | ||
|
||
You can have both a configuration file and environment variables; if you do, the values of the environment variables take precedence over the values in the config file. | ||
|
||
## Other environment variables | ||
|
||
If Smeagol is compiled as an executable jar file, the actual web server component is [Ring server](https://github.com/weavejester/ring-server). This recognises the `PORT` environment variable, and, if this is present and its value is a positive integer, will listen on the specified port (otherwise its default is 3000, which is... unusual). | ||
|
||
Smeagol uses the [Timbre](https://github.com/ptaoussanis/timbre) logging library. This recognises the following environment variables: | ||
|
||
1. `TIMBRE_DEFAULT_STACKTRACE_FONTS` Timbre by default colourises stacktrace dumps using ANSI terminal codes. This can be quite useful in a console, but is a real pain in a log file. To turn colourised stacktraces off, set the value of this to an empty string; | ||
2. `TIMBRE_LEVEL` Sets the minimum logging level; but there are two problems with this. The first is that the environment variable is only read at compile time not at run time, and the second is that the syntax is a bit odd, which is why I've implemented `SMEAGOL_LOG_LEVEL` (above); | ||
3. `TIMBRE_NS_WHITELIST` Sets a list of [Clojure namespaces](https://clojure.org/reference/namespaces) from which messages should be logged; however this is only read at compile time so isn't much use in practice; | ||
4. `TIMBRE_NS_BLACKLIST` As above, but sets a list of namespaces from which messages should **not** be logged. |
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
Binary file not shown.
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
Oops, something went wrong.