๐Ÿงถ

Alpine Linux + Poetry + Fastapi + Firecracker

Dockerfile

FROM python:3.9-alpine as python ENV PYTHONUNBUFFERED=true WORKDIR /app FROM python as poetry ENV POETRY_HOME=/opt/poetry ENV POETRY_VIRTUALENVS_IN_PROJECT=true ENV PATH="$POETRY_HOME/bin:$PATH" # trying alpine again here manually RUN apk add gcc curl musl-dev --no-cache RUN python -c 'from urllib.request import urlopen; print(urlopen("https://install.python-poetry.org").read().decode())' | python - COPY . ./ RUN poetry install --no-interaction --no-ansi -vvv FROM python as runtime RUN apk update \ && apk add --no-cache curl openrc openssh libffi-dev util-linux python3 py3-pip gcc musl-dev py3-setuptools python3-dev libc-dev rust cargo make ca-certificates \ && ssh-keygen -A \ && echo "root:dummy_passwd"|chpasswd \ && ln -s agetty /etc/init.d/agetty.ttyS0 \ && echo ttyS0 > /etc/securetty \ && rc-update add agetty.ttyS0 default \ && rc-update add devfs boot \ && rc-update add procfs boot \ && rc-update add sysfs boot \ && rc-update add local default ENV PATH="/app/.venv/bin:$PATH" COPY --from=poetry /app /app EXPOSE 8000 RUN apk del \ curl \ gcc \ libressl-dev \ musl-dev \ libffi-dev CMD ["uvicorn", "main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"]
ย 

Shit this container does that I love