diff --git a/site/deploy/Dockerfile b/site/deploy/Dockerfile new file mode 100644 index 0000000..57b1619 --- /dev/null +++ b/site/deploy/Dockerfile @@ -0,0 +1,23 @@ +FROM --platform=linux/amd64 ubuntu:20.04 AS base +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ruby-full ruby-bundler python3 \ + git build-essential zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* \ + && groupadd -g 1000 jekyll \ + && useradd -mu 1000 -g jekyll jekyll +USER jekyll +WORKDIR /home/jekyll +ENV GEM_HOME=/home/jekyll/gems \ + PATH="/home/jekyll/gems/bin:${PATH}" +COPY Gemfile Gemfile.lock ./ +RUN bundle install + +FROM base AS generate +COPY --chown=jekyll:jekyll . ./src +WORKDIR /home/jekyll/src +RUN bundle exec jekyll build --destination /home/jekyll/build --trace + +FROM nginx:1.21-alpine +COPY ./deploy/default.conf /etc/nginx/conf.d/default.conf +COPY --from=generate /home/jekyll/build /usr/share/nginx/html \ No newline at end of file diff --git a/site/deploy/default.conf b/site/deploy/default.conf new file mode 100644 index 0000000..ff920b4 --- /dev/null +++ b/site/deploy/default.conf @@ -0,0 +1,21 @@ +server { + listen 80; + server_name localhost; + default_type text/html; + + root /usr/share/nginx/html; + + location / { + index index.html index.htm; + } + + location /post { + try_files $uri $uri.html; + } + + #error_page 404 /404.html; + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/site/deploy/docker.sh b/site/deploy/docker.sh new file mode 100755 index 0000000..2c66d8c --- /dev/null +++ b/site/deploy/docker.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +docker build --network host -f deploy/Dockerfile --tag $IMGREPO . + +# M1 Mac users may need to use buildx to specify the proper platform for the build. +# Comment out the line above and uncomment this one as necessary. +# docker buildx build -f deploy/Dockerfile --tag $IMGREPO --platform=linux/amd64 . + +docker push $IMGREPO + +# Uncomment to run a container locally using the new image (for testing). +# docker run --rm -it -p 127.0.0.1:8080:80 $IMGREPO \ No newline at end of file