-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch to pdm, cache builds better, pin postgres version
- Loading branch information
1 parent
e758fec
commit b982eaa
Showing
9 changed files
with
962 additions
and
1,633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name: validate-signoff | ||
|
||
on: | ||
pull_request: | ||
types: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/penumbra/projects/other/pythonista/pythonista-bot/.venv/bin/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,36 @@ | ||
FROM python:3.12-slim | ||
ARG PYTHON_BASE=3.12-slim | ||
|
||
FROM python:${PYTHON_BASE} AS builder | ||
|
||
# disable update check since we're "static" in an image | ||
ENV PDM_CHECK_UPDATE=false | ||
# install PDM | ||
RUN pip install -U pdm | ||
|
||
WORKDIR /project | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get install --no-install-recommends --no-install-suggests -y git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN --mount=type=cache,target=/project/.venv/,sharing=locked \ | ||
--mount=type=bind,source=pyproject.toml,target=/project/pyproject.toml,readwrite \ | ||
--mount=type=bind,source=pdm.lock,target=/project/pdm.lock,readwrite \ | ||
pdm install --check --prod --no-editable && \ | ||
cp -R /project/.venv /project/.ready-venv | ||
|
||
FROM python:${PYTHON_BASE} | ||
|
||
LABEL org.opencontainers.image.source=https://github.com/PythonistaGuild/Pythonista-Bot | ||
LABEL org.opencontainers.image.description="Pythonista Guild's Discord Bot" | ||
LABEL org.opencontainers.image.licenses=MIT | ||
|
||
ENV PYTHONUNBUFFERED=1 \ | ||
# prevents python creating .pyc files | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
\ | ||
# pip | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 \ | ||
\ | ||
# poetry | ||
# https://python-poetry.org/docs/configuration/#using-environment-variables | ||
# make poetry install to this location | ||
POETRY_HOME="/opt/poetry" \ | ||
# make poetry create the virtual environment in the project's root | ||
# it gets named `.venv` | ||
POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
# do not ask any interactive question | ||
POETRY_NO_INTERACTION=1 \ | ||
\ | ||
# paths | ||
# this is where our requirements + virtual environment will live | ||
PYSETUP_PATH="/opt/pysetup" \ | ||
VENV_PATH="/opt/pysetup/.venv" | ||
|
||
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" | ||
|
||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
git \ | ||
# deps for installing poetry | ||
curl \ | ||
# deps for building python deps | ||
build-essential \ | ||
libcurl4-gnutls-dev \ | ||
gnutls-dev \ | ||
libmagic-dev | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python - | ||
|
||
# copy project requirement files here to ensure they will be cached. | ||
USER 1000:1000 | ||
|
||
WORKDIR /app | ||
COPY poetry.lock pyproject.toml ./ | ||
|
||
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally | ||
RUN poetry install --only=main | ||
COPY --from=builder --chown=1000:1000 /project/.ready-venv/ /app/.venv | ||
ENV PATH="/app/.venv/bin:$PATH" | ||
|
||
COPY . /app/ | ||
ENTRYPOINT ["poetry", "run", "python", "-O", "launcher.py" ] | ||
ENTRYPOINT [ "python", "-O", "launcher.py" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.