-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
90 lines (59 loc) · 1.87 KB
/
Dockerfile
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
78
79
80
81
82
83
84
85
86
87
88
89
90
FROM python:3.9 AS builder
ARG POETRY_VERSION=1.2.1
# Disable stdout/stderr buffering, can cause issues with Docker logs
ENV PYTHONUNBUFFERED=1
# Disable some obvious pip functionality
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
# Configure poetry
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_PATH=/venvs
# Install taglib
RUN apt-get update && \
apt-get install --no-install-recommends -y libtag1-dev && \
rm -rf /var/lib/apt/lists
# Install Poetry
# hadolint ignore=DL3013
RUN pip install -U pip wheel setuptools && \
pip install "poetry==$POETRY_VERSION"
WORKDIR /app
COPY pyproject.toml poetry.lock /app/
#
# prod-build
#
FROM builder AS prod-build
# Create virtualenv and install dependencies
# hadolint ignore=SC1091
RUN python -m venv /venv && . /venv/bin/activate && poetry install --only=main --no-root
RUN /venv/bin/python -m iscc_sdk.install
COPY . /app/
#
# frontend-build
#
FROM node:16.17.0 AS frontend-build
RUN npm install -g pnpm
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install
COPY . .
RUN pnpm run build
#
# prod-runtime
#
FROM python:3.9-slim AS prod-runtime
LABEL org.opencontainers.image.source=https://github.com/iscc/iscc-web
RUN apt-get update && apt-get install --no-install-recommends -y libmagic1 libtag1v5-vanilla && rm -rf /var/lib/apt/lists
# Disable stdout/stderr buggering, can cause issues with Docker logs
ENV PYTHONUNBUFFERED=1
ENV PATH="/venv/bin:$PATH"
ENV VIRTUAL_ENV=/venv
ENV ISCC_WEB_ENVIRONMENT=production
ENV PORT=8000
COPY --from=prod-build /root/.local/share/iscc-sdk /root/.local/share/iscc-sdk
COPY --from=prod-build /root/.ipfs /root/.ipfs
COPY --from=prod-build /app /app
COPY --from=prod-build /venv /venv
COPY --from=frontend-build /app/iscc_web/static/dist /app/iscc_web/static/dist
WORKDIR /app
EXPOSE 8000/tcp
CMD ["gunicorn", "iscc_web.main:app", "-k", "uvicorn.workers.UvicornWorker"]