Browse Source

Docker-ize the static site

JL-10/add-doppler-secrets-support
lavenderguitar 3 years ago
parent
commit
797880799f
  1. 23
      site/deploy/Dockerfile
  2. 21
      site/deploy/default.conf
  3. 12
      site/deploy/docker.sh

23
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

21
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;
}
}

12
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
Loading…
Cancel
Save