Dockerfile 1.18 KB
Newer Older
Christopher Guindon's avatar
Christopher Guindon committed
1
2
3
4
ARG NGINX_IMAGE_TAG=stable-alpine-for-hugo

FROM debian:10-slim AS builder

5
ARG HUGO_VERSION=0.76.5
Christopher Guindon's avatar
Christopher Guindon committed
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
ARG NODE_VERSION=10.15.0

RUN apt-get update && apt-get install -y \
    build-essential \
    ca-certificates \
    curl \
    git \
    --no-install-recommends

RUN curl -L -o /tmp/node.tar.xz "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" \
    && mkdir -p /usr/local/lib/nodejs \
    && tar -xJf /tmp/node.tar.xz -C /usr/local/lib/nodejs \
    && ln -s /usr/local/lib/nodejs/node-v${NODE_VERSION}-linux-x64/bin/node /usr/bin/node \
    && ln -s /usr/local/lib/nodejs/node-v${NODE_VERSION}-linux-x64/bin/npm /usr/bin/npm \
    && ln -s /usr/local/lib/nodejs/node-v${NODE_VERSION}-linux-x64/bin/npx /usr/bin/npx

RUN curl -L -o /tmp/hugo.deb "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.deb" \
    && dpkg -i /tmp/hugo.deb

WORKDIR /workdir
COPY . /workdir/

RUN echo -n "Node.js version " && node --version \
  && echo -n "npm version " && npm --version \
  && hugo version

RUN npm --unsafe-perm ci \
    && hugo

FROM eclipsefdn/nginx:${NGINX_IMAGE_TAG}

COPY --from=builder /workdir/public/ /usr/share/nginx/html/