aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMantas Vilčinskas <11616378+mistermantas@users.noreply.github.com>2020-06-29 18:33:44 +0300
committerGitHub <noreply@github.com>2020-06-29 18:33:44 +0300
commita2d976250aa7e91ffb8f216611fc262315bf7094 (patch)
treea9d0559fefffe8a24594748eed6393c5202f6774
parentb524c3401ccb89be4e53d92868a38e7ecf459d00 (diff)
parentdee88bbd1a285ccff920027e11147fb357841ca5 (diff)
Docker support #119 thanks to @Nevexo
-rw-r--r--Dockerfile19
-rw-r--r--docker/entrypoint.sh21
2 files changed, 40 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..721b64a
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,19 @@
+FROM nginx:alpine
+
+# /cstate will be our volume & building directory
+WORKDIR /cstate
+
+# Install hugo & git
+RUN apk add hugo git
+
+# -- First Run --
+
+# Download the example site
+RUN git clone https://github.com/cstate/example /cstate
+
+# Copy files from this repo into themes/cstate
+RUN mkdir -p /cstate/themes/cstate
+COPY . /cstate/themes/cstate
+
+# Prepare the entrypoint files
+COPY ./docker/entrypoint.sh /docker-entrypoint.d/10-build-hugo.sh \ No newline at end of file
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
new file mode 100644
index 0000000..f8068c1
--- /dev/null
+++ b/docker/entrypoint.sh
@@ -0,0 +1,21 @@
+WORK_DIR="/app"
+SRC_DIR="/cstate"
+
+# Check if the working dir is empty, if it is we'll need to copy
+# the files in from src directory (usually /cstate)
+if ! [ "$(ls -A $WORK_DIR)" ]; then
+ # First run, copy cstate's files in.
+ echo "First time run! Hello, World :)"
+ cp -R $SRC_DIR/* $WORK_DIR
+fi
+
+# Continue with building
+
+# CD into working dir
+cd /app
+
+# Build the hugo site
+hugo
+
+# Copy built files into NGINX directory
+cp -r /app/public/* /usr/share/nginx/html \ No newline at end of file