This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Dockerfile
67 lines (53 loc) · 1.67 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
FROM alpine:3.8 as build-env
WORKDIR /site
#build env
ENV ASCIIDOCTOR_VERSION=2.0.10
ENV HUGO_VERSION=0.69.0
ENV HUGO_DOWNLOAD_URL=https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz
RUN apk add --update --no-cache --virtual build-dependencies
# install some build prereqs
RUN apk add --update --no-cache \
bash \
build-base \
ca-certificates \
curl \
git \
libcurl \
libxml2-dev \
libxslt-dev \
openssh \
rsync \
ruby \
ruby-dev \
wget
# install gems
RUN gem install \
asciidoctor:${ASCIIDOCTOR_VERSION} \
html-proofer \
nokogiri \
--no-document && \
apk del build-dependencies
# download and install hugo
RUN wget "$HUGO_DOWNLOAD_URL" && \
tar xzf hugo_${HUGO_VERSION}_Linux-64bit.tar.gz && \
mv hugo /usr/bin/hugo && \
rm hugo_${HUGO_VERSION}_Linux-64bit.tar.gz LICENSE README.md || true
#copy the entire website folder into the build environment container
COPY . ./
#actually build the site
RUN hugo
# lets create the actual deployment image
FROM nginx:alpine
#copy over the site config for nginx
COPY ./.docker/default.conf /etc/nginx/conf.d/default.conf
#copy over the built website from the build environment docker
COPY --from=build-env /site/public /usr/share/nginx/html
# change permissions to allow running as arbitrary user
RUN chmod -R 777 /var/log/nginx /var/cache/nginx /var/run \
&& chgrp -R 0 /etc/nginx \
&& chmod -R g+rwX /etc/nginx
# use a different user as open shift wants non-root containers
# do it at the end here as it'll block our "root" commands to set the container up
USER 1000
#expose 8081 as we cant use port 80 on openshift (non-root restriction)
EXPOSE 8081