-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile
77 lines (49 loc) · 1.51 KB
/
Containerfile
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
FROM public.ecr.aws/docker/library/golang:1.19-alpine3.16 AS hugo-builder
WORKDIR /src
RUN apk upgrade --update-cache \
&& apk add ca-certificates git gcc g++ musl-dev \
&& git clone --depth 1 'https://github.com/gohugoio/hugo'
WORKDIR /src/hugo
ENV CGO_ENABLED=1
RUN go build --tags extended
FROM public.ecr.aws/docker/library/alpine:3.16 AS python-base
RUN apk upgrade --no-cache \
&& apk add ca-certificates git python3
FROM python-base AS python-builder
RUN apk upgrade --no-cache \
&& apk add py3-pip make
ENV VIRTUAL_ENV="/opt/venv"
COPY . /src/
WORKDIR /src
RUN python3 -m venv "${VIRTUAL_ENV}" \
&& . "${VIRTUAL_ENV}/bin/activate" \
&& pip install -U pip \
&& pip install -U build \
&& make build \
&& make install
FROM python-base
RUN apk upgrade --no-cache \
&& apk add --no-cache libstdc++ libgcc openssh-client
COPY --from=hugo-builder --chown=root:root --chmod=0755 /src/hugo/hugo /usr/bin/hugo
ENV VIRTUAL_ENV="/opt/venv"
COPY --from=python-builder "${VIRTUAL_ENV}" "${VIRTUAL_ENV}"
ARG UID=10000
ARG GID=10001
RUN mkdir -p /var/lib/hugo \
&& addgroup -g "${GID}" -S _hugo \
&& adduser \
-u "${UID}" \
-h /var/lib/hugo \
-g 'hugo privsep user' \
-s /sbin/nologin \
-G _hugo \
-S _hugo \
&& chown -R _hugo:_hugo /var/lib/hugo
VOLUME ["/var/lib/hugo"]
WORKDIR "/var/lib/hugo"
USER _hugo
EXPOSE 8000
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENTRYPOINT ["python3"]
CMD ["-m", "hwwwook"]
# vim:ft=dockerfile