Commit e62b6896 authored by TonyFord's avatar TonyFord
Browse files

add deployment files

parent 6d48bcf5
Pipeline #1080 failed with stages
in 5 minutes and 50 seconds
stages:
- build
- start
- stop
- uninstall
build-jekyll:
stage: build
tags:
- FairCoin.Co
only:
refs:
- master
variables:
- $CMD =~ /build/
before_script:
- export RUNNER_UID=`id -u`
- export RUNNER_GID=`id -g`
script:
- docker-compose down
- docker-compose build
start-jekyll:
stage: start
tags:
- FairCoin.Co
only:
refs:
- master
variables:
- $CMD =~ /build|start/
before_script:
- export RUNNER_UID=`id -u`
- export RUNNER_GID=`id -g`
script:
- docker-compose stop
- docker-compose up -d
stop-jekyll:
stage: stop
tags:
- FairCoin.Co
only:
refs:
- master
variables:
- $CMD =~ /stop/
script:
- docker-compose stop
uninstall-jekyll:
stage: uninstall
tags:
- FairCoin.Co
only:
refs:
- master
variables:
- $CMD =~ /uninstall/
script:
- docker-compose stop
- docker-compose down
FROM ruby:2.7.1-alpine
COPY . .
# --
# EnvVars
# Ruby
# --
ENV BUNDLE_HOME=/usr/local/bundle
ENV BUNDLE_APP_CONFIG=/usr/local/bundle
ENV BUNDLE_BIN=/usr/local/bundle/bin
ENV GEM_BIN=/usr/gem/bin
ENV GEM_HOME=/usr/gem
# --
# EnvVars
# Image
# --
ENV JEKYLL_VAR_DIR=/var/jekyll
ENV JEKYLL_VERSION=4.0.0
ENV JEKYLL_DATA_DIR=/var/www
ENV JEKYLL_BIN=/usr/jekyll/bin
ENV JEKYLL_ENV=production
# --
# EnvVars
# System
# --
ENV LANG=de_DE.UTF-8
ENV LANGUAGE=de_DE:en
ENV TZ=Europe/Berlin
ENV PATH="$JEKYLL_BIN:$PATH"
ENV PATH="$GEM_BIN:$PATH"
ENV LC_ALL=de_DE.UTF-8
ENV LANG=de_DE.UTF-8
ENV LANGUAGE=de_DE
# --
# EnvVars
# Main
# --
ENV VERBOSE=false
ENV FORCE_POLLING=false
ENV DRAFTS=false
# --
# Packages
# User
# --
RUN apk --no-cache add \
ruby-dev \
build-base \
curl \
vim \
wget \
bash
# --
# Packages
# Dev
# --
RUN apk --no-cache add \
zlib-dev \
build-base \
libxml2-dev \
libxslt-dev \
readline-dev \
libffi-dev \
yaml-dev \
zlib-dev \
cmake
# --
# Packages
# Main
# --
RUN apk --no-cache add \
linux-headers \
openjdk8-jre \
less \
zlib \
libxml2 \
readline \
libxslt \
libffi \
git \
nodejs \
tzdata \
shadow \
su-exec \
nodejs-npm \
libressl \
yarn
# --
# Gems
# Update
# --
RUN echo "gem: --no-ri --no-rdoc" > ~/.gemrc
RUN unset GEM_HOME && unset GEM_BIN && \
yes | gem update --system
# --
# Gems
# Main
# --
# Work around a nonsense RubyGem permission bug.
RUN unset GEM_HOME && unset GEM_BIN && yes | gem install --force bundler
RUN gem install jekyll -v$JEKYLL_VERSION -- \
--use-system-libraries
RUN bundle install
# --
ARG RUNNER_GID
ARG RUNNER_UID
RUN addgroup -Sg $RUNNER_GID jekyll
RUN adduser -Su $RUNNER_UID -G \
jekyll jekyll
# --
COPY entrypoint.sh $JEKYLL_BIN/entrypoint
RUN chown jekyll:jekyll $JEKYLL_BIN/entrypoint
RUN chmod u+x $JEKYLL_BIN/entrypoint
# --
RUN mkdir -p $JEKYLL_VAR_DIR
RUN mkdir -p $JEKYLL_DATA_DIR
RUN chown -R jekyll:jekyll $JEKYLL_DATA_DIR
RUN chown -R jekyll:jekyll $JEKYLL_VAR_DIR
RUN chown -R jekyll:jekyll $BUNDLE_HOME
# --
RUN rm -rf /root/.gem
RUN rm -rf /home/jekyll/.gem
RUN rm -rf $BUNDLE_HOME/cache
RUN rm -rf $GEM_HOME/cache
# --
CMD ["jekyll", "--help"]
ENTRYPOINT ["/usr/jekyll/bin/entrypoint"]
WORKDIR /var/www
VOLUME /var/www
version: "3.1"
services:
jekyll:
build:
context: ./
args:
RUNNER_UID: "${RUNNER_UID}"
RUNNER_GID: "${RUNNER_GID}"
container_name: faircoin.co-jekyll
command: jekyll build --watch --force_polling --verbose
user: "${RUNNER_UID}:${RUNNER_GID}"
volumes:
- .:/var/www
php-server:
restart: always
container_name: faircoin.co-jekyll-php
image: php:7
command: php -S 0.0.0.0:4000 -t /srv/jekyll/_site
env_file:
- ${FAIRCOIN_CONF}
depends_on:
- jekyll
ports:
- ${LH_PORT}:4000
volumes:
- .:/var/www
#!/bin/bash
[ "$DEBUG" = "false" ] && set -x
set -e
# --
# Running rootless means that we force Jekyll to run
# entirely as 'root'. This is substituted by the container
# to the uid of the actual user.
# --
if [ "$JEKYLL_ROOTLESS" ]; then
JEKYLL_UID=0
JEKYLL_GID=0
fi
# --
: ${JEKYLL_UID:=$(id -u jekyll)}
: ${JEKYLL_GID:=$(id -g jekyll)}
# --
export JEKYLL_UID
export JEKYLL_GID
# --
# Users can customize our UID's to fit their own so that
# we don't have to chown constantly. Well it's not like
# we do so much of it (anymore) it's slow, but we do
# change permissions which can result in some bad
# behavior on OS X.
# --
if [ "$JEKYLL_UID" != "0" ] && [ "$JEKYLL_UID" != "$(id -u jekyll)" ]; then
usermod -u $JEKYLL_UID jekyll
groupmod -g $JEKYLL_GID jekyll
chown_args=""
[ "$FULL_CHOWN" ] && chown_args="-R"
for d in "$JEKYLL_DATA_DIR" "$JEKYLL_VAR_DIR"; do
chown $chown_args jekyll:jekyll "$d"
done
fi
# --
# Make sure JEKYLL matches the UID/GID
# This will most likely end up as 1
# --
if [ "$JEKYLL_ROOTLESS" ]; then
usermod -o -u $JEKYLL_UID jekyll
groupmod -o -g $JEKYLL_GID jekyll
fi
# --
exec "$@"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment