12 Commits

Author SHA1 Message Date
fb81d51e29 Use default node user & dumb-init & remove config assumptions
By default the wiki will run in farm mode with friends security
2019-11-16 16:49:43 -07:00
5e6f732fed Bump wiki to version 0.19.0 2019-08-14 12:07:10 -04:00
f85afce8c8 Change base image to node:10-alpine & wiki to 0.17.0 2019-03-27 22:26:09 -06:00
76280f3e7b Update wiki to 0.16.2 2019-03-11 08:00:53 -06:00
356afda8a7 Update wiki version for security fix 2018-11-27 21:10:15 -08:00
e9bd94e860 remind myself how to publish plugin experiments 2018-02-28 08:23:21 -07:00
b0be20f5f3 point to local-farm.wiki.dbbs.co instead 2018-02-25 22:32:46 -07:00
26329ee584 upgrade to wiki-0.14.0 and move configure-wiki to separate step
We should only need to run the configure-wiki script once instead of
every time we start the container.  Also, I don't think that script
was correctly handling PID 1 role (e.g. don't think we forwarded
signals to node nor reaped zombies)
2018-02-25 21:58:43 -07:00
e37d746c69 upgrade to node-8 and to wiki-0.13.0 2017-12-11 08:02:50 -07:00
86548c594a upgrade to wiki 0.12.2
includes update to client and several plugins:
calendar, markdown, and html
2017-11-06 18:00:57 -07:00
ef34fdc759 enable github-based npm packages for WIKI_PACKAGE
npm needs git installed in order to install packages from github
2017-10-02 07:10:55 -06:00
e22b66240d enabled building scoped packages & bumped version to 0.12.1 2017-09-20 17:50:00 -06:00
4 changed files with 52 additions and 172 deletions

View File

@ -1,19 +1,16 @@
FROM node:4-slim
FROM node:lts-alpine
RUN useradd --create-home app \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
jq
WORKDIR /home/app
ARG VERSION=0.12.0
RUN su app -c "npm install -g --prefix . wiki@$VERSION"
RUN su app -c "mkdir .wiki"
COPY configure-and-launch-wiki set-owner-name ./
RUN chown app configure-and-launch-wiki set-owner-name
VOLUME "/home/app/.wiki"
ENV DOMAIN=localhost
ENV OWNER_NAME="The Owner"
ENV COOKIE=insecure
RUN apk add --update --no-cache \
dumb-init \
git \
jq
WORKDIR "/home/node"
ARG WIKI_PACKAGE=wiki@0.19.0
RUN su node -c "npm install -g --prefix . $WIKI_PACKAGE"
RUN su node -c "mkdir -p .wiki"
VOLUME "/home/node/.wiki"
EXPOSE 3000
USER app
CMD ["./configure-and-launch-wiki"]
USER node
ENV PATH="${PATH}:/home/node/bin"
ENTRYPOINT ["dumb-init"]
CMD ["wiki", "--farm", "--security_type=friends"]

View File

@ -1,59 +1,58 @@
# Federated Wiki Farm
http://fed.wiki.org
Start Playing Federated Wiki: http://start.fed.wiki
### Get acquainted with wiki.
### Run a local wiki farm
Launch the container:
``` bash
docker run -p 3000:3000 -it --rm \
dobbs/farm
```
docker run -p 3000:3000 -it --rm \
dobbs/farm
Visit http://localhost:3000
Visit http://localhost:3000 and http://anything.localtest.me:3000
### Make your wiki survive a reboot
### Run a local wiki that will survive a reboot
Create a volume:
docker run -p 3000:3000 -it --rm \
-v ~/.wiki:/home/node/.wiki \
dobbs/farm
``` bash
docker volume create dot-wiki
```
Your wiki pages and configuration will be saved in the ~/.wiki folder.
Launch the container:
``` bash
docker run -p 3000:3000 -it --rm \
-v dot-wiki:/home/app/.wiki \
dobbs/farm
```
# Release Notes for 1.0.0
Visit http://localhost:3000
This is a significant **breaking** change from pre-1.0 releases. Especially:
### Make your wiki a local farm
* changed the user from `app` (`uid=1001(app) gid=1001(app) groups=1001(app)`)
to `node` (`uid=1000(node) gid=1000(node) groups=1000(node),1000(node)`)
We're going to use http://localtest.me instead of localhost for our
domain name. See http://readme.localtest.me for more info.
* no longer installing `bash`, `configure-wiki`, nor `set-owner-name`
Let's also use a different volume for this one:
``` bash
docker volume create localtest.me
```
* no longer creating `/home/app/.wiki/wiki.json`
Specify the domain name when you launch your wiki
``` bash
docker run -p 3000:3000 -it --rm \
-v localtest.me:/home/app/.wiki \
-e DOMAIN=localtest.me \
dobbs/farm
```
Those changes in particular will impose some work on authors upgrading
from previous versions.
Open http://this.localtest.me:3000 in one tab.
Open http://that.localtest.me:3000 in another.
The last non-breaking revision is 0.52.0 https://github.com/dobbs/farm/tree/0.52.0#readme
# Development
This image's tag does not match the version of the included wiki software.
Notes to self:
``` bash
VERSION=0.12.0
docker build --build-arg VERSION=$VERSION -t dobbs/farm:$VERSION .
git tag -am "" $VERSION
docker build --tag dobbs/farm:0.51.0 .
git tag -am "" '0.51.0'
git push --tags
```
The repos in Dockerhub and GitHub are configured to automatically build new tags.
# Publish experimental plugins
``` bash
docker build \
--tag dobbs/farm:0.14.0-frame \
--build-arg WIKI_PACKAGE='dobbs/wiki#frame' \
.
docker push dobbs/farm:0.14.0-frame
```

View File

@ -1,77 +0,0 @@
#!/bin/bash -eu
set -o pipefail
main() {
initialize-environment-vars
assert-file-privileges || report-errors-and-exit
ensure-owner-file
ensure-config-file
show-configs
exec-wiki
}
initialize-environment-vars() {
ERRORS=''
readonly OWNER_FILE=/home/app/.wiki/$DOMAIN.owner.json
readonly CONFIG_FILE=/home/app/.wiki/config.json
}
assert-file-privileges() {
[ -w /home/app/.wiki ] \
|| ERRORS="app cannot write to /home/app/.wiki\n${ERRORS}"
[ ${#ERRORS} == 0 ]
}
report-errors-and-exit() {
echo -e $ERRORS
echo "exiting."
exit 1
}
ensure-owner-file() {
if [ ! -r "$OWNER_FILE" ]; then
jq -n --arg name "$OWNER_NAME" --arg secret $(random-string) \
'.name = $name | .friend.secret = $secret' > $OWNER_FILE
fi
}
ensure-config-file() {
if [ ! -r "$CONFIG_FILE" ]; then
> $CONFIG_FILE \
jq -n -M \
--arg admin $(jq -r .friend.secret $OWNER_FILE) \
--arg random $(random-string) \
--arg cookie $COOKIE \
--arg domain $DOMAIN \
--arg owner $OWNER_FILE \
'
.admin = $admin
| .autoseed = true
| .farm = true
| .cookieSecret = $random
| .secure_cookie = ("secure" == $cookie)
| .security_type = "friends"
| .wikiDomains[$domain].id = "/home/app/.wiki/\($domain).owner.json"
'
fi
}
random-string() {
node -e 'console.log(require("crypto").randomBytes(64).toString("hex"))'
}
show-configs() {
set -x
ls -l $OWNER_FILE $CONFIG_FILE
cat $OWNER_FILE
cat $CONFIG_FILE
set +x
}
exec-wiki() {
exec /home/app/bin/wiki
}
main

View File

@ -1,39 +0,0 @@
#!/bin/bash -eu
set -o pipefail
usage() {
cat <<EOF
Usage: $(basename $0) NAME
replaces the owner's name in $OWNER_FILE
EOF
}
main() {
initialize-environment-vars $@ || { usage; exit 1; }
backup-and-save-name
report-success
}
initialize-environment-vars() {
readonly OWNER_FILE=/home/app/.wiki/$DOMAIN.owner.json
readonly OWNER_BACKUP_FILE=$OWNER_FILE-saved-$(date --iso-8601=minutes)
readonly NAME=${@:-missing}
[ ! "$NAME" == "missing" ]
}
backup-and-save-name() {
mv $OWNER_FILE $OWNER_BACKUP_FILE
jq ".name = \"$NAME\"" $OWNER_BACKUP_FILE > $OWNER_FILE
}
report-success() {
cat <<EOF
Owner's name changed to "$NAME"
Previous config is saved in ${OWNER_BACKUP_FILE##$PWD/}
EOF
}
main "$@"