Skip to content

Commit

Permalink
Create new Docker setup with s6-overlay (#193)
Browse files Browse the repository at this point in the history
Fixes #193 

* ✨ ⛵ Create new Docker setup with s6-overlay

* 👕 Fix errors

* 🔨 remove jq

* 🔨 Add missing argument

* 🔨 Cleanup

* 🔨 Copy built app

* 🔥 Fix build path

* 🔨 remove stage not required

* 🚑 Add missing mime types

* 🔨 Create nicer default file

* 🔨 tweak default file

* 🔨 Remove test

* ⛵ Update docker-compose file

* 🔨 Fix docker-compose volumes

* 📚 Update docs for new setup
  • Loading branch information
timmo001 authored Jan 9, 2019
1 parent 0c8b04e commit dba365f
Show file tree
Hide file tree
Showing 16 changed files with 402 additions and 138 deletions.
3 changes: 1 addition & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include: https://raw.githubusercontent.com/timmo001/organization/master/gitlab-c
variables:
GITHUB_REPO: "timmo001/home-panel"
SLUG: "home-panel"
TARGET: "."
TARGET: "docker"

AARCH64: "true"
AMD64: "true"
Expand All @@ -21,6 +21,5 @@ variables:
PREFLIGHT_YAMLLINT: "true"
PREFLIGHT_ESLINT: "true"
PREFLIGHT_STYLELINT: "false"
TEST: "true"
PUBLISH_RELEASE_FILE: "true"
PAGES_MKDOCS: "true"
79 changes: 0 additions & 79 deletions Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions docker-compose.yml

This file was deleted.

89 changes: 89 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
ARG BUILD_FROM=alpine:3.8
# hadolint ignore=DL3006
FROM ${BUILD_FROM}

# Environment variables
ENV \
HOME="/root" \
LANG="C.UTF-8" \
PS1="$(whoami)@$(hostname):$(pwd)$ " \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
S6_CMD_WAIT_FOR_SERVICES=1 \
TERM="xterm" \
SSL="false" \
SSL_CERTFILE="/data/ssl/fullchain.pem" \
SSL_KEYFILE="/data/ssl/privkey.pem"

# Copy app
COPY build /opt/panel

# Copy root filesystem
COPY rootfs /

# Build arch argument
ARG BUILD_ARCH=amd64

# Set shell
SHELL ["/bin/ash", "-o", "pipefail", "-c"]

# Install system
# hadolint ignore=DL3003
RUN \
set -o pipefail \
\
&& echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories \
&& echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories \
&& echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
\
&& apk add --no-cache --virtual .build-dependencies \
curl=7.61.1-r1 \
git=2.18.1-r0 \
tar=1.30-r0 \
yarn=1.7.0-r0 \
\
&& apk add --no-cache \
apk-tools=2.10.1-r0 \
bash=4.4.19-r1 \
busybox=1.28.4-r2 \
ca-certificates=20171114-r3 \
nginx=1.14.2-r0 \
nodejs-current=9.11.1-r2 \
tzdata=2018f-r0 \
\
&& if [ "${BUILD_ARCH}" = "i386" ]; then S6_ARCH="x86"; else S6_ARCH="${BUILD_ARCH}"; fi \
\
&& curl -L -s "https://github.com/just-containers/s6-overlay/releases/download/v1.21.7.0/s6-overlay-${S6_ARCH}.tar.gz" \
| tar zxvf - -C / \
\
&& mkdir -p /etc/fix-attrs.d \
\
&& git clone --depth=1 \
"https://github.com/timmo001/home-panel-api.git" /opt/api \
\
&& cd /opt/api \
&& yarn install \
\
&& yarn cache clean \
&& apk del --purge .build-dependencies \
&& rm -fr /tmp/*

# Entrypoint & CMD
ENTRYPOINT ["/init"]

# Build arguments
ARG BUILD_DATE
ARG BUILD_REF
ARG BUILD_VERSION

# Labels
LABEL \
maintainer="Timmo <contact@timmo.xyz>" \
org.label-schema.description="A touch-compatible web-app for controlling the home" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="Home Panel" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://git.timmo.xyz/home-panel" \
org.label-schema.usage="https://github.com/timmo001/home-panel/tree/master/README.md" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-url="https://github.com/timmo001/home-panel" \
org.label-schema.vendor="Timmo"
13 changes: 13 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
version: '3'

services:
home-panel:
image: timmo001/home-panel
ports:
- 3234:3234
- 8234:8234
volumes:
- ~/home-panel-config.json:/data/config.json
- ~/ssl/fullchain.pem:/data/ssl/fullchain.pem
- ~/ssl/privkey.pem:/data/ssl/privkey.pem
11 changes: 11 additions & 0 deletions docker/rootfs/etc/cont-finish.d/99-message.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# ==============================================================================
# Displays an message right before terminating in case something went wrong
# ==============================================================================

if [[ "${S6_STAGE2_EXITED}" -ne 0 ]]; then
echo '-----------------------------------------------------------'
echo ' Oops! Something went wrong.'
echo ' Be sure to check the log above, line by line, for hints.'
echo '-----------------------------------------------------------'
fi
7 changes: 7 additions & 0 deletions docker/rootfs/etc/cont-init.d/00-banner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Displays a simple banner on startup
# ==============================================================================
echo '-----------------------------------------------------------'
echo 'Home Panel'
echo '-----------------------------------------------------------'
9 changes: 9 additions & 0 deletions docker/rootfs/etc/cont-init.d/10-nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Configures NGINX for use with Home Panel
# ==============================================================================
# Enable SSL
if [ -f "$SSL_CERTFILE" ]; then
sed -i "s/%%certfile%%/${SSL_CERTFILE}/g" /etc/nginx/nginx-ssl.conf
sed -i "s/%%keyfile%%/${SSL_KEYFILE}/g" /etc/nginx/nginx-ssl.conf
fi
Loading

0 comments on commit dba365f

Please sign in to comment.