forked from Tiryoh/docker-mkdocs-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.alpine
50 lines (42 loc) · 1.43 KB
/
Dockerfile.alpine
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
FROM python:3.8.7-alpine3.11
ARG MKDOCS_ENV=production
ENV MKDOCS_ENV=${MKDOCS_ENV} \
# python:
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PYTHONDONTWRITEBYTECODE=1 \
# pip:
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# poetry:
POETRY_VERSION=1.1.4 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
PATH="$PATH:/root/.poetry/bin"
# Install system deps
RUN apk add --no-cache \
bash git gcc musl-dev libxml2-dev libxslt-dev && \
apk add --no-cache --virtual .build curl && \
# Installing `poetry` package manager:
# https://github.com/python-poetry/poetry
curl -sSL 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py' | python && \
poetry --version && \
apk del .build
# Copy only requirements to cache them in docker layer
COPY poetry.lock pyproject.toml /docs/
# Set working directory
WORKDIR /docs
# Initialize project
RUN echo "MKDOCS_ENV: "${MKDOCS_ENV} && \
poetry install \
$(if [ "$MKDOCS_ENV" = 'production' ]; then echo '--no-dev'; fi) \
--no-interaction --no-ansi && \
if [ "$MKDOCS_ENV" = 'production' ]; then rm -rf "$POETRY_CACHE_DIR"; fi
# Expose MkDocs development server port
EXPOSE 8000
# Start development server by default
ENTRYPOINT ["mkdocs"]
CMD ["serve", "--dev-addr=0.0.0.0:8000"]