feat: use layered docker image
This commit is contained in:
parent
214d04a2ad
commit
c9993a7f70
1 changed files with 18 additions and 10 deletions
28
Dockerfile
28
Dockerfile
|
|
@ -1,18 +1,26 @@
|
|||
FROM hugomods/hugo:exts
|
||||
FROM hugomods/hugo:exts AS builder
|
||||
|
||||
RUN apk update && apk add nginx
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
|
||||
# Create a non-root user to own the files and run our server
|
||||
RUN adduser -D static
|
||||
RUN hugo -d public -b https://adriano.fyi
|
||||
|
||||
RUN chown -R static:static /home/static && mkdir -p /var/lib/nginx/tmp/client_body && chown -R static:static /var/lib/nginx
|
||||
FROM alpine:latest
|
||||
|
||||
# Copy the static website
|
||||
# Use the .dockerignore file to control what ends up inside the image!
|
||||
COPY . /home/static
|
||||
RUN apk update && apk add --no-cache nginx && \
|
||||
adduser -D static
|
||||
|
||||
RUN mkdir -p /var/lib/nginx/tmp/client_body && \
|
||||
chown -R static:static /var/lib/nginx /home/static && \
|
||||
chmod -R 755 /home/static
|
||||
|
||||
WORKDIR /home/static
|
||||
RUN hugo -d public -b https://adriano.fyi
|
||||
|
||||
COPY --from=builder /src/nginx.conf /home/static/nginx.conf
|
||||
|
||||
COPY --from=builder --chown=static:static /src/public /home/static/public
|
||||
|
||||
USER static
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["nginx", "-e", "/dev/stderr", "-c", "/home/static/nginx.conf" ]
|
||||
|
||||
ENTRYPOINT ["nginx", "-e", "/dev/stderr", "-c", "/home/static/nginx.conf"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue