Browse Source

Added a Dockerfile for easy setup for newcomers.

keep-around/680f276adee19e514916e88d277bb6af781ccb1b
Evilham 1 year ago
parent
commit
e846a102f4
3 changed files with 84 additions and 1 deletions
  1. +30
    -0
      Dockerfile
  2. +19
    -1
      README.md
  3. +35
    -0
      docker_init.sh

+ 30
- 0
Dockerfile View File

@@ -0,0 +1,30 @@
# Learn more about the Docker images here:
# https://gitlab.com/paddy-hack/devuan/blob/master/README.md


# Things won't work with ruby 2.5 on beowulf, someone should look into that.
FROM registry.gitlab.com/paddy-hack/devuan:ascii

RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
build-essential ruby ruby-dev zlib1g-dev libcurl3 pandoc git

RUN gem install rake middleman && gem install bundler

# Pre-install requisites to allow for quick subsequent webpage builds
RUN mkdir -p /devuan-www/src
COPY Gemfile /devuan-www/Gemfile
COPY Gemfile.lock /devuan-www/Gemfile.lock
RUN cd /devuan-www && bundle install --path /devuan-www/vendor/bundle

# If /devuan-www/src/Gemfile does not exist, following repo will be cloned
# You could e.g. mount /devuan-www/src as a docker volume
ENV DEVUAN_WWW_REPO https://git.devuan.org/devuan-editors/devuan-www.git
ENV DEVUAN_WWW_BRANCH master

# Built site will be placed in a `public` subdir
# A build log will be placed in `build.log`
ENV DEVUAN_DIR_OUT /devuan-www/out

COPY docker_init.sh /docker_init.sh
CMD ./docker_init.sh

+ 19
- 1
README.md View File

@@ -44,7 +44,25 @@ add their own custom contents for their local community.

## Development

To deploy the site locally:
**Note**: the easiest way to setup a build environment is by using the
provided `Dockerfile`. Even if you don't want to use docker, you may want to
use both `Dockerfile` and `docker_init.sh` as reference to setup your build
environment.

### Using docker

* Build the image with `docker build -t devuan-www .`
* Adapt following to your needs:

mkdir /tmp/devuan-www
docker run -it \
--mount type=bind,source=/tmp/devuan-www,target=/devuan-www/out \
--mount type=bind,source=$(pwd),target=/devuan-www/src \
devuan-www

* Now `/tmp/devuan-www` will contain a `build.log` file with useful
information and a `public` directory with the built site.
* See below for information on how to serve the webpage.

### 0. Pre-requisites



+ 35
- 0
docker_init.sh View File

@@ -0,0 +1,35 @@
#!/bin/sh

DEVUAN_DIR="/devuan-www/src"

# Only clone main repo if directory does not exist
if [ ! -f "${DEVUAN_DIR}/Gemfile" ]; then
git clone --single-branch --branch "${DEVUAN_WWW_BRANCH}" "${DEVUAN_WWW_REPO}" "${DEVUAN_DIR}"
fi

cd "${DEVUAN_DIR}"

if [ ! -d "${DEVUAN_DIR}/.bundle" ]; then
mkdir "${DEVUAN_DIR}/.bundle"
fi

tee "${DEVUAN_DIR}/.bundle/config" << EOF
---
BUNDLE_PATH: "${DEVUAN_DIR}/../vendor/bundle"
BUNDLE_DISABLE_SHARED_GEMS: "true"
EOF

if [ ! -f "${DEVUAN_DIR}/config.rb" ]; then
cp "${DEVUAN_DIR}/config.rb.dist" "${DEVUAN_DIR}/config.rb"
fi

# Create output dir if needed
mkdir -p "${DEVUAN_DIR_OUT}"||true
# Remove old files if needed
if [ -d "${DEVUAN_DIR_OUT}/public" ]; then
rm -r "${DEVUAN_DIR_OUT}/public"
fi
# Build and pipe log to output dir
bundle exec middleman build --verbose 2>&1 | tee "${DEVUAN_DIR_OUT}/build.log"
# Place result in output dir
mv public "${DEVUAN_DIR_OUT}"

Loading…
Cancel
Save