-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile.prod
51 lines (38 loc) · 1.44 KB
/
Dockerfile.prod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# This file is used if building for Production environments
# It uses a multi-stage build to run jekyll to populate an nginx container
FROM docker.io/library/ruby:3.1 as build
# Add Gem build requirements
RUN apt-get update && apt-get install -y \
g++ \
make \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Add Gemfile and Gemfile.lock
ADD Gemfile* /app/
# Install Gems
RUN gem install bundler -v 2.4.5 \
&& bundle config build.nokogiri --use-system-libraries \
&& bundle config --global jobs $(nproc) \
&& bundle config set deployment 'true' \
&& bundle config set no-cache 'true' \
&& bundle install \
&& bundle clean
# Copy Site Files
COPY . .
ENV JEKYLL_ENV=production
# Run jekyll build site
RUN bundle exec jekyll build --verbose
#-------------------------------------------------
# https://github.com/nginxinc/docker-nginx-unprivileged
FROM ghcr.io/nginxinc/nginx-unprivileged:stable-alpine as webserver
RUN echo "absolute_redirect off;" >/etc/nginx/conf.d/no-absolute_redirect.conf
RUN echo "gzip_static on; gzip_proxied any;" >/etc/nginx/conf.d/gzip_static.conf
# brotli_static not yet available in standard nginx distribution
# RUN echo "brotli_static on; brotli_proxied any;" >/etc/nginx/conf.d/brotli_static.conf
# Copy built site from build stage
COPY --from=build /app/_site /usr/share/nginx/html
# Test configuration during docker build
RUN nginx -t
# Port the container will listen on
EXPOSE 8080