-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add resource metrics Add psutil memory info metrics
- Loading branch information
Showing
54 changed files
with
1,650 additions
and
62 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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,70 @@ | ||
FROM camptocamp/c2cwsgiutils AS base-all | ||
LABEL maintainer Camptocamp "info@camptocamp.com" | ||
SHELL ["/bin/bash", "-o", "pipefail", "-cux"] | ||
|
||
# Used to convert the locked packages by poetry to pip requirements format | ||
# We don't directly use `poetry install` because it force to use a virtual environment. | ||
FROM base-all AS poetry | ||
|
||
RUN --mount=type=cache,target=/var/lib/apt/lists \ | ||
--mount=type=cache,target=/var/cache,sharing=locked \ | ||
apt-get update \ | ||
&& apt-get install --assume-yes --no-install-recommends python-is-python3 | ||
|
||
# Install Poetry | ||
WORKDIR /tmp | ||
COPY requirements.txt ./ | ||
RUN python3 -m pip install --disable-pip-version-check --requirement=requirements.txt | ||
|
||
# Do the conversion | ||
COPY poetry.lock pyproject.toml ./ | ||
RUN poetry export --output=requirements.txt \ | ||
&& poetry export --with=dev --output=requirements-dev.txt | ||
|
||
# Base, the biggest thing is to install the Python packages | ||
FROM base-all AS base | ||
|
||
WORKDIR /app | ||
|
||
EXPOSE 8080 | ||
RUN --mount=type=cache,target=/root/.cache \ | ||
--mount=type=bind,from=poetry,source=/tmp,target=/poetry \ | ||
python3 -m pip install --disable-pip-version-check --no-deps --requirement=/poetry/requirements.txt | ||
|
||
COPY . /app | ||
|
||
ARG GIT_HASH | ||
|
||
RUN --mount=type=cache,target=/root/.cache \ | ||
python3 -m pip install --disable-pip-version-check --no-deps --editable=. \ | ||
&& python3 -m pip freeze > /requirements.txt | ||
RUN ./models_graph.py > models.dot \ | ||
&& ./models_graph.py Hello > models-hello.dot \ | ||
&& c2cwsgiutils-genversion $GIT_HASH \ | ||
&& python3 -m compileall -q . | ||
|
||
ENV \ | ||
DOCKER_RUN=1 \ | ||
DEVELOPMENT=0 \ | ||
SQLALCHEMY_POOL_RECYCLE=30 \ | ||
SQLALCHEMY_POOL_SIZE=5 \ | ||
SQLALCHEMY_MAX_OVERFLOW=25 \ | ||
SQLALCHEMY_SLAVE_POOL_RECYCLE=30 \ | ||
SQLALCHEMY_SLAVE_POOL_SIZE=5 \ | ||
SQLALCHEMY_SLAVE_MAX_OVERFLOW=25 \ | ||
LOG_TYPE=console \ | ||
OTHER_LOG_LEVEL=WARNING \ | ||
GUNICORN_LOG_LEVEL=WARNING \ | ||
SQL_LOG_LEVEL=WARNING \ | ||
C2CWSGIUTILS_LOG_LEVEL=WARNING \ | ||
LOG_LEVEL=INFO \ | ||
VISIBLE_ENTRY_POINT=/ | ||
|
||
RUN mkdir -p /prometheus-metrics \ | ||
&& chmod a+rwx /prometheus-metrics | ||
ENV PROMETHEUS_MULTIPROC_DIR=/prometheus-metrics | ||
|
||
# www-data | ||
USER 33 | ||
|
||
CMD ["/venv/bin/gunicorn", "--paste=/app/production.ini"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
...ce_tests/app/c2cwsgiutils_app/__init__.py → ...gunicorn_app/c2cwsgiutils_app/__init__.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
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
File renamed without changes.
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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
acceptance_tests/app/models_graph.py → ...ptance_tests/gunicorn_app/models_graph.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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,24 @@ | ||
#!/bin/bash | ||
# Upgrade the DB | ||
set -au | ||
|
||
# wait for the DB to be UP | ||
while ! echo "import sqlalchemy; sqlalchemy.create_engine('${SQLALCHEMY_URL}').connect()" | python3 2> /dev/null; do | ||
echo "Waiting for the DB to be reachable" | ||
sleep 1 | ||
done | ||
|
||
for ini in *alembic*.ini; do | ||
if [[ -f "${ini}" ]]; then | ||
echo "${ini} ===========================" | ||
echo History | ||
alembic -c "${ini}" history | ||
echo Head | ||
alembic -c "${ini}" head | ||
echo Upgrade | ||
alembic -c "${ini}" upgrade head | ||
echo Current | ||
alembic -c "${ini}" current | ||
echo "===========================" | ||
fi | ||
done |
2 changes: 1 addition & 1 deletion
2
acceptance_tests/app/scripts/wait-db → ...ptance_tests/gunicorn_app/scripts/wait-db
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
Oops, something went wrong.