diff --git a/Dockerfile b/Dockerfile index 7ae03a6..3293d7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY setup /setup RUN (cd /setup; sh bootstrap.sh) # Set the work directory to blog -WORKDIR /blog +WORKDIR /config # Start the server -CMD ["/bin/bash", "/blog/run.sh"] +CMD ["/bin/bash", "/setup/run.sh"] diff --git a/setup/bootstrap.sh b/setup/bootstrap.sh index fd85784..72515af 100755 --- a/setup/bootstrap.sh +++ b/setup/bootstrap.sh @@ -6,24 +6,3 @@ apt-get -y install rsync # Install HEXO npm install -g hexo - -# Check to ensure the /config volume is mounted -if [ ! -d "/config" ]; then - echo "Please mount a /config directory so you blog persists upon container restarts!" - echo "If this is your first time setting up the container make sure the /config directory is empty!" - exit 1 -fi - -echo "Linking configs to blog runtime dir..." -ln -s /config /blog - -if [ -z "$(ls -A /config)" ]; then - echo "Blog not yet initialized, setting up the default files..." - # Initilize the blog - hexo init /blog -else - echo "Blog already initialized, skipping..." -fi - -# Copy bootstrap scrpt -cp /setup/run.sh /blog/run.sh diff --git a/setup/run.sh b/setup/run.sh index 8f08afb..ff502be 100755 --- a/setup/run.sh +++ b/setup/run.sh @@ -1,5 +1,20 @@ #!/bin/bash +# Check to ensure the /config volume is mounted +if [ ! -d "/config" ]; then + echo "Please mount a /config directory so you blog persists upon container restarts!" + echo "If this is your first time setting up the container make sure the /config directory is empty!" + exit 1 +fi + +if [ -z "$(ls -A /config)" ]; then + echo "Blog not yet initialized, setting up the default files..." + # Initilize the blog + hexo init /config +else + echo "Blog already initialized, skipping..." +fi + # Install any required hexo plugins if [[ -z "${HEXO_PLUGINS}" ]]; then echo "No additional plugins to install!" @@ -12,5 +27,6 @@ fi echo "Starting hexo server on port 8080" # Start fresh +cd /config || exit 1 hexo clean || true hexo server -p 8080 --debug --draft