Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Dockerfile for pristine Foswiki setup #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
ARG base=debian:11
FROM $base

ARG url=https://github.com/foswiki/distro/releases/download/FoswikiRelease02x01x07/Foswiki-2.1.7.tgz
ARG sha512=7196ce5a586a3770e2d198a79d0856f34724893746a40500b7f72d3efc48dcbdfb0292a3583186cf4e5b217a70df3b5dd8af80aa3e5c34987ca202a62dada0bf
ARG root=/var/www/foswiki
ARG user=www-data
ARG group=www-data
ARG port=80
ARG lang=C.UTF-8
ARG tz=Asia/Shanghai
ARG mirror=""

ENV LANG=$lang TZ=$tz

RUN set -eux; \
[ -z "$mirror" ] || sed -i -E "s|http(s?)://deb.debian.org|$mirror|" /etc/apt/sources.list; \
apt update -y \
&& apt install -y curl diffutils grep less logrotate vim w3m \
apache2 libapache2-mod-fcgid libapache2-mod-perl2 nginx \
libalgorithm-diff-perl \
libapache2-request-perl \
libarchive-zip-perl \
libcgi-session-perl \
libconvert-pem-perl \
libcrypt-eksblowfish-perl \
libcrypt-passwdmd5-perl \
libcrypt-smime-perl \
libcrypt-x509-perl \
libdbd-mariadb-perl \
libdbd-mysql-perl \
libdbd-pg-perl \
libdbd-sqlite3-perl \
libemail-address-xs-perl \
libemail-mime-perl \
libemail-simple-perl \
liberror-perl \
libfcgi-procmanager-perl \
libfile-copy-recursive-perl \
libfile-mmagic-xs-perl \
libjson-perl \
liblocale-codes-perl \
liblocale-maketext-lexicon-perl \
liblocale-msgfmt-perl \
&& apt install -y --no-install-recommends \
libimage-magick-perl \
&& rm -rf /var/lib/apt/lists/* \
&& a2enmod access_compat rewrite \
&& a2dissite 000-default \
&& rm /etc/nginx/sites-enabled/default

RUN set -eux; \
mkdir -p $root \
&& cd $root \
&& curl -L -s -o foswiki.tgz "$url" \
&& echo "$sha512 foswiki.tgz" > foswiki.tgz.sha512 \
&& sha512sum -c --status foswiki.tgz.sha512 \
&& tar -xzvf foswiki.tgz --strip-components=1 \
&& rm foswiki.tgz foswiki.tgz.sha512 \
&& sh tools/fix_file_permissions.sh \
&& chown -R $user:$group $root \
&& echo "0,30 * * * * cd $root/bin && perl ../tools/tick_foswiki.pl" | crontab -u $user - \
&& cp tools/foswiki.init-script /etc/init.d/foswiki \
&& chmod 755 /etc/init.d/foswiki \
&& update-rc.d foswiki defaults \
&& cp tools/foswiki.defaults /etc/default/foswiki \
&& chmod 644 /etc/default/foswiki

COPY foswiki-apache.conf /etc/apache2/sites-enabled/foswiki.conf
COPY foswiki-nginx.conf /etc/nginx/sites-enabled/foswiki.conf
COPY start.sh /start.sh

VOLUME $root

EXPOSE $port

CMD ["/bin/sh", "/start.sh"]
21 changes: 21 additions & 0 deletions docker/LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Yubao Liu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
64 changes: 64 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Dockerfile for Foswiki

Run pristine Foswiki in Debian container with Apache 2 + mod_fcgid/mod_proxy_fcgi/mod_perl or Nginx.

## Build

```sh
docker build . -t foswiki --progress plain
```

Notice this Dockerfile uses volume for `/var/www/foswiki`.

## Run

```sh
# Use Apache, may use `-e MODULE=[fcigd|proxy_fcgi|perl]` to choose different Apache module.
docker run -dt --init --name foswiki -p 8888:80 -e TZ=Asia/Shanghai -e HTTPD=apache foswiki


# Use Nginx
docker run -dt --init --name foswiki -p 8888:80 -e TZ=Asia/Shanghai foswiki
```

Access http://localhost:8888 to further configure Foswiki:

1. http://localhost:8888/bin/configure
1. `Security and Authentication` -> `Registration`: select `Enable User Registration`
2. `General settings` -> `File System Paths`: set `Safe PATH` to `/bin:/usr/bin`
3. Click button `Save 2 changes` on the top right corner
2. http://localhost:8888/System/UserRegistration Register your first user, such as WikiName `FirstAdmin`
3. http://localhost:8888/Main/WikiGroups Click `Add Members...` in the group `AdminGroup`, add newly registered user's WikiName
4. Run `docker restart foswiki` to restart the Docker container

Although you can directly access Foswiki in the container, this container is expected to be behind a reverse proxy that terminates HTTPS connections and handles virtual site, you must replace the hostname above to `https://your-reverse-proxy?SSL=1`.

## Extensions

Highly recommended extension for Nginx:

``` sh
su -s /bin/bash www-data
cd /var/www/foswiki
tools/extension_installer XSendFileContrib -r install
tools/configure -save -set '{XSendFileContrib}{Header}=X-Accel-Redirect'
tools/configure -save -set '{XSendFileContrib}{Location}=/files'
```

Beautiful skin extension [NatSkin](https://foswiki.org/Extensions/NatSkin):
``` sh
su -s /bin/bash www-data
cd /var/www/foswiki
tools/extension_installer NatSkin -r install
```

Check https://foswiki.org/Extensions for more extensions.

## Reference

* https://github.com/timlegge/docker-foswiki
* https://foswiki.org/System/InstallationGuide
* https://foswiki.org/System/InstallationGuidePart2
* https://foswiki.org/Support/FoswikiOnNginx
* https://foswiki.org/System/FastCGIEngineContrib#Nginx

Loading