Compare commits
1 Commits
1.0.0
...
0.13.0-app
Author | SHA1 | Date | |
---|---|---|---|
29980517f6 |
32
Dockerfile
32
Dockerfile
@ -1,16 +1,20 @@
|
|||||||
FROM node:lts-alpine
|
FROM node:8-slim
|
||||||
|
|
||||||
RUN apk add --update --no-cache \
|
RUN useradd --create-home app \
|
||||||
dumb-init \
|
&& apt-get update \
|
||||||
git \
|
&& apt-get install -y --no-install-recommends \
|
||||||
jq
|
jq \
|
||||||
WORKDIR "/home/node"
|
git
|
||||||
ARG WIKI_PACKAGE=wiki@0.19.0
|
WORKDIR /home/app
|
||||||
RUN su node -c "npm install -g --prefix . $WIKI_PACKAGE"
|
ARG WIKI_PACKAGE='dobbs/wiki#apparatus'
|
||||||
RUN su node -c "mkdir -p .wiki"
|
RUN su app -c "npm install -g --prefix . $WIKI_PACKAGE"
|
||||||
VOLUME "/home/node/.wiki"
|
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
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
USER node
|
USER app
|
||||||
ENV PATH="${PATH}:/home/node/bin"
|
CMD ["./configure-and-launch-wiki"]
|
||||||
ENTRYPOINT ["dumb-init"]
|
|
||||||
CMD ["wiki", "--farm", "--security_type=friends"]
|
|
||||||
|
72
README.md
72
README.md
@ -1,58 +1,62 @@
|
|||||||
# Federated Wiki Farm
|
# Federated Wiki Farm
|
||||||
|
|
||||||
Start Playing Federated Wiki: http://start.fed.wiki
|
http://fed.wiki.org
|
||||||
|
|
||||||
### Run a local wiki farm
|
### Get acquainted with wiki.
|
||||||
|
|
||||||
docker run -p 3000:3000 -it --rm \
|
Launch the container:
|
||||||
dobbs/farm
|
``` bash
|
||||||
|
docker run -p 3000:3000 -it --rm \
|
||||||
|
dobbs/farm
|
||||||
|
```
|
||||||
|
|
||||||
Visit http://localhost:3000 and http://anything.localtest.me:3000
|
Visit http://localhost:3000
|
||||||
|
|
||||||
### Run a local wiki that will survive a reboot
|
### Make your wiki survive a reboot
|
||||||
|
|
||||||
docker run -p 3000:3000 -it --rm \
|
Create a volume:
|
||||||
-v ~/.wiki:/home/node/.wiki \
|
|
||||||
dobbs/farm
|
|
||||||
|
|
||||||
Your wiki pages and configuration will be saved in the ~/.wiki folder.
|
``` bash
|
||||||
|
docker volume create dot-wiki
|
||||||
|
```
|
||||||
|
|
||||||
# Release Notes for 1.0.0
|
Launch the container:
|
||||||
|
``` bash
|
||||||
|
docker run -p 3000:3000 -it --rm \
|
||||||
|
-v dot-wiki:/home/app/.wiki \
|
||||||
|
dobbs/farm
|
||||||
|
```
|
||||||
|
|
||||||
This is a significant **breaking** change from pre-1.0 releases. Especially:
|
Visit http://localhost:3000
|
||||||
|
|
||||||
* changed the user from `app` (`uid=1001(app) gid=1001(app) groups=1001(app)`)
|
### Make your wiki a local farm
|
||||||
to `node` (`uid=1000(node) gid=1000(node) groups=1000(node),1000(node)`)
|
|
||||||
|
|
||||||
* no longer installing `bash`, `configure-wiki`, nor `set-owner-name`
|
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 creating `/home/app/.wiki/wiki.json`
|
Let's also use a different volume for this one:
|
||||||
|
``` bash
|
||||||
|
docker volume create localtest.me
|
||||||
|
```
|
||||||
|
|
||||||
Those changes in particular will impose some work on authors upgrading
|
Specify the domain name when you launch your wiki
|
||||||
from previous versions.
|
``` bash
|
||||||
|
docker run -p 3000:3000 -it --rm \
|
||||||
|
-v localtest.me:/home/app/.wiki \
|
||||||
|
-e DOMAIN=localtest.me \
|
||||||
|
dobbs/farm
|
||||||
|
```
|
||||||
|
|
||||||
The last non-breaking revision is 0.52.0 https://github.com/dobbs/farm/tree/0.52.0#readme
|
Open http://this.localtest.me:3000 in one tab.
|
||||||
|
Open http://that.localtest.me:3000 in another.
|
||||||
|
|
||||||
# Development
|
# Development
|
||||||
|
|
||||||
This image's tag does not match the version of the included wiki software.
|
This image's tag matches the version of the included wiki software.
|
||||||
|
|
||||||
Notes to self:
|
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
docker build --tag dobbs/farm:0.51.0 .
|
git tag -am "" '0.13.0'
|
||||||
git tag -am "" '0.51.0'
|
|
||||||
git push --tags
|
git push --tags
|
||||||
```
|
```
|
||||||
|
|
||||||
The repos in Dockerhub and GitHub are configured to automatically build new 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
|
|
||||||
```
|
|
||||||
|
77
configure-and-launch-wiki
Executable file
77
configure-and-launch-wiki
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
#!/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
|
39
set-owner-name
Executable file
39
set-owner-name
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/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 "$@"
|
Reference in New Issue
Block a user