generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
130 lines (110 loc) · 3.7 KB
/
Dockerfile
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Note: this Dockerfile uses a multistage build to prevent the final image from being unnecessarily large. During a build, each RUN command
# creates a new layer that persists into the final image, even if packages installed early on are later uninstalled before
# the end of the Dockerfile. To avoid this, most of the installation takes place during stage one, then only the github-pages gem is
# copied over into stage 2.
###
### BUILD STAGE 1
###
# The FROM command specifies a base image to start with. We're using an Alpine Linux base because it's small (around 5MB), together with a Ruby installation
# that matches GitHub Pages' current Ruby version (2.7.3-alpine3.13 as of 08/03/2022, ruby:2.7.4-alpine3.14 as of 8/18/2022)
FROM ruby:2.7.4-alpine3.14 AS build
# Set Ruby ENV variables
ENV GEM_BIN=/usr/gem/bin
ENV GEM_HOME=/usr/gem
# Linux package installation
# (Some of the following are needed to install the github-pages gem later on,
# but some are likely not needed at all; maybe a good future project to sift out the ones that aren't.)
#
# Install development packages (via apk --> "Alpine Package Keeper")
RUN apk --no-cache add \
zlib-dev \
libffi-dev \
build-base \
libxml2-dev \
imagemagick-dev \
readline-dev \
libxslt-dev \
libffi-dev \
yaml-dev \
zlib-dev \
vips-dev \
vips-tools \
sqlite-dev \
cmake
# Install main packages
RUN apk --no-cache add \
linux-headers \
openjdk8-jre \
less \
zlib \
libxml2 \
readline \
libxslt \
libffi \
git \
nodejs \
tzdata \
shadow \
npm \
libressl \
yarn
# Update currently installed Gems
RUN echo "gem: --no-ri --no-rdoc" > ~/.gemrc
RUN unset GEM_HOME && unset GEM_BIN && \
yes | gem update --system
# Install github-pages gem.
# This gem bundles all dependencies required by GitHub Pages, including Jekyll.
#
# (When no version number is specified, it will install the most recent version available. (v227, as of 08/03/2022)
# To specify a version, use "gem install github-pages:<version_number>")
RUN gem install github-pages -- \
--use-system-libraries
###
### BUILD STAGE 2
###
FROM ruby:2.7.4-alpine3.14
LABEL maintainer "Jordon Bedwell <[email protected]>"
# Copy shell scripts from the Dockerfile directory into the root of the new build stage.
# (It may be possible to create an image without these; maybe a future project to look into removing them.)
COPY copy/all /
# Set Ruby ENV variables again for new build stage
ENV GEM_BIN=/usr/gem/bin
ENV GEM_HOME=/usr/gem
# Set ENV variables for new build stage
ENV JEKYLL_BIN=/usr/jekyll/bin
# Set system ENV variables
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV TZ=America/Chicago
ENV PATH="$JEKYLL_BIN:$PATH"
ENV LC_ALL=en_US.UTF-8
ENV LANGUAGE=en_US
# Install bash and su-exec. These are required by the shell scripts we copied over right after starting build stage 2.
RUN apk --no-cache add \
bash \
su-exec
# Copy the github-pages gem we installed during stage 1 into an identical folder within the new build stage.
COPY --from=build /usr/gem/ /usr/gem/
RUN addgroup -Sg 1000 jekyll
RUN adduser -Su 1000 -G \
jekyll jekyll
RUN mkdir -p /var/jekyll
RUN mkdir -p /srv/jekyll
RUN chown -R jekyll:jekyll /srv/jekyll
RUN chown -R jekyll:jekyll /var/jekyll
RUN rm -rf /home/jekyll/.gem
RUN rm -rf /usr/gem/cache
RUN rm -rf /root/.gem
# The below pertains to an issue with the bundler package manager. We don't currently use it in this image,
# but we'll leave it commented out in case it's needed again someday.
#
# # Work around rubygems/rubygems#3572
# RUN mkdir -p /usr/gem/cache/bundle
# RUN chown -R jekyll:jekyll \
# /usr/gem/cache/bundle
CMD ["jekyll", "--help"]
ENTRYPOINT ["/usr/jekyll/bin/entrypoint"]
WORKDIR /srv/jekyll
VOLUME /srv/jekyll
EXPOSE 35729
EXPOSE 4000