1908: Optimize docs/Dockerfile r=mergify[bot] a=Erriez

- Convert .rst to .html in temporary `python:3.8-alpine3.14` build image
- Remove all unused packages
- Use `nginx:1.21-alpine` deployment image

## What type of PR?

Optimize/fix `docs/Dockerfile`

## What does this PR do?

### Related issue(s)
- Mention an issue like: #1851

## Prerequistes
Before we can consider review and merge, please make sure the following list is done and checked.
If an entry in not applicable, you can check it or remove it from the list.

- [ ] In case of feature or enhancement: documentation updated accordingly
- [ ] Unless it's docs or a minor change: add [changelog](https://mailu.io/master/contributors/workflow.html#changelog) entry file.

## Testing

The following tests has been executed locally:

```bash
export DOCKER_ORG=user
export DOCKER_PREFIX=
export MAILU_VERSION=master

cd tests
time docker-compose -f build.yml build --no-cache docs
	real	0m18.850s
	user	0m0.317s
	sys	0m0.124s

docker images
	REPOSITORY                   TAG               IMAGE ID       CREATED              SIZE
	user/docs                    master            3de6c8612cf3   19 seconds ago       38.1MB

docker run -it --rm --name mailu-docs -p 80:80 user/docs:master

Open web browser:
	Clear caches
	http://localhost:80/master
```

Co-authored-by: Erriez <Erriez@users.noreply.github.com>
master
bors[bot] 3 years ago committed by GitHub
commit bfb2665d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,19 +1,28 @@
ARG DISTRO=python:3.8-alpine3.14 # Convert .rst files to .html in temporary build container
FROM $DISTRO FROM python:3.8-alpine3.14 AS build
COPY requirements.txt /requirements.txt
ARG version=master ARG version=master
ENV VERSION=$version ENV VERSION=$version
RUN apk add --no-cache nginx curl \ COPY requirements.txt /requirements.txt
&& pip3 install -r /requirements.txt
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY . /docs COPY . /docs
RUN mkdir -p /build/$VERSION \ RUN apk add --no-cache --virtual .build-deps \
&& sphinx-build -W /docs /build/$VERSION gcc musl-dev \
&& pip3 install -r /requirements.txt \
&& mkdir -p /build/$VERSION \
&& sphinx-build -W /docs /build/$VERSION \
&& apk del .build-deps
# Build nginx deployment image including generated html
FROM nginx:1.21-alpine
ARG version=master
ENV VERSION=$version
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /build/$VERSION /build/$VERSION
EXPOSE 80/tcp EXPOSE 80/tcp

Loading…
Cancel
Save