From 48b6af280230eda803163728e77a42887c66fdd0 Mon Sep 17 00:00:00 2001 From: William Miceli Date: Fri, 3 Jan 2020 18:56:43 -0500 Subject: [PATCH] First upload of necessary files Let's see what happens... --- .dockerignore | 1 + .gitlab-ci.yml | 60 ++++++++++++++++++++++++++++++++++ Dockerfile | 38 +++++++++++++++++++++ README.md | 9 ++++- entrypoint.sh | 7 ++++ etc/nginx/conf.d/DokuWiki.conf | 43 ++++++++++++++++++++++++ 6 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100644 entrypoint.sh create mode 100644 etc/nginx/conf.d/DokuWiki.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5ee7e30 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +*/.git/* \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a750b00 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,60 @@ +image: docker:latest + +stages: + - Build Base + - Push Images + +0-build-base: + stage: Build Base + artifacts: + expire_in: 1 week + paths: + - ./Artifacts/ + tags: + - docker + before_script: + - mkdir ./Artifacts + script: + - docker build --pull --build-arg "RELEASE_VERSION=$RELEASE_VERSION" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" . + - docker save --output "./Artifacts/$CI_COMMIT_SHORT_SHA.tar" "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" + +1A-push-dev: + stage: Push Images + dependencies: + - 0-build-base + tags: + - docker + before_script: + - docker load --input "./Artifacts/$CI_COMMIT_SHORT_SHA.tar" + - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin + script: + - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:dev-$RELEASE_VERSION-$CI_PIPELINE_ID" + - docker push "$CI_REGISTRY_IMAGE:dev-$RELEASE_VERSION-$CI_PIPELINE_ID" + +1B-push-version: + stage: Push Images + dependencies: + - 0-build-base + tags: + - docker + when: manual + before_script: + - docker load --input "./Artifacts/$CI_COMMIT_SHORT_SHA.tar" + - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin + script: + - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:$RELEASE_VERSION" + - docker push "$CI_REGISTRY_IMAGE:$RELEASE_VERSION" + +1C-push-latest: + stage: Push Images + dependencies: + - 0-build-base + tags: + - docker + when: manual + before_script: + - docker load --input "./Artifacts/$CI_COMMIT_SHORT_SHA.tar" + - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin + script: + - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:latest" + - docker push "$CI_REGISTRY_IMAGE:latest" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b852827 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM alpine:3.11 +LABEL maintainer="William Miceli " +USER root +WORKDIR / + +ARG RELEASE_VERSION + +# So that OpenRC works properly +VOLUME [ “/sys/fs/cgroup” ] + +# Copying in startup script +COPY /entrypoint.sh / + +# Copying in nginx configuration +COPY /etc/ /etc/ + +# Adding required packages +RUN apk update && apk add --no-cache\ + nano \ + nginx \ + openrc \ + php7-fpm \ + php7-gd \ + && rm /etc/nginx/conf.d/default.conf + +# Adding DokuWiki +RUN rm -rf /var/www/* \ + && wget -O /var/www/DokuWiki.tar.gz https://github.com/splitbrain/dokuwiki/archive/release_stable_2018-04-22b.tar.gz \ + && tar -xvzf /var/www/DokuWiki.tar.gz -C /var/www/ \ + && rm /var/www/DokuWiki.tar.gz \ + && DIRECTORY=$(ls /var/www) \ + && mv /var/www/$DIRECTORY/* /var/www/ \ + && rm -rf /var/www/$DIRECTORY \ + && unset DIRECTORY + +# Expose Insecure Web, MySQL Server +EXPOSE 80 +CMD ["/bin/sh", "/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 883e3ed..0e4a311 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ # DokuWiki on Docker -[GitHub Releases](https://github.com/splitbrain/dokuwiki/releases) \ No newline at end of file +[GitHub Releases](https://github.com/splitbrain/dokuwiki/releases) + +This is a very vanilla image of DokuWiki following the official instructions as closely as I can pay attention... + + +## Important Reminder + +Make sure that once you've completed installing DokuWiki through your browser at `yourdomain.tld/install.php` that you uncomment out the `location ~ /(conf/|bin/|inc/|install.php) { deny all; }` line in the nginx config. \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..8bfefa2 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +echo "[ INFO ] Starting PHP Service" +rc-service php-fpm7 start + +echo "[ INFO ] Starting nginx" +nginx -g "daemon off;" # Foreground diff --git a/etc/nginx/conf.d/DokuWiki.conf b/etc/nginx/conf.d/DokuWiki.conf new file mode 100644 index 0000000..921a7e2 --- /dev/null +++ b/etc/nginx/conf.d/DokuWiki.conf @@ -0,0 +1,43 @@ +server { + listen 80; + listen [::]:80; + server_name _; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + root /var/www/; + index doku.php; + + client_max_body_size 64M; + client_body_buffer_size 128k; + + #Remember to comment the below out when you're installing, and uncomment it when done. + #location ~ /(conf/|bin/|inc/|install.php) { deny all; } + + #Support for X-Accel-Redirect + location ~ ^/data/ { internal ; } + + location ~ ^/lib.*\.(js|css|gif|png|ico|jpg|jpeg)$ { + expires 365d; + } + + location / { try_files $uri $uri/ @dokuwiki; } + + location @dokuwiki { + # rewrites "doku.php/" out of the URLs if you set the userwrite setting to .htaccess in dokuwiki config page + rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; + rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; + rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; + rewrite ^/(.*) /doku.php?id=$1&$args last; + } + + location ~ \.php$ { + try_files $uri $uri/ /doku.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param REDIRECT_STATUS 200; + fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; + # fastcgi_pass unix:/var/run/php5-fpm.sock; #old php version + } +}