Commit graph

55 commits

Author SHA1 Message Date
moson-mo
32461f28ea
fix(docker): Suppress error PEP-668
When using docker (compose), we don't create a venv and just install
python packages system-wide.

With python 3.11 (PEP 668) we need to explicitly tell pip to allow this.

Signed-off-by: moson-mo <mo-son@mailbox.org>
2023-06-15 14:19:02 +02:00
moson-mo
8ca63075e9
housekeep: remove PHP implementation
removal of the PHP codebase

Signed-off-by: moson-mo <mo-son@mailbox.org>
2023-04-28 16:10:32 +02:00
Leonidas Spyropoulos
ef2baad7b3
feat: expand on update.py tests and show on Gitlab UI
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
2023-01-27 17:16:25 +00:00
Kevin Morris
a2d08e441e
fix(docker): run pre-commit run -a once
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-09-11 17:59:45 -07:00
Leonidas Spyropoulos
310c469ba8
fix: run pre-commit checks instead of flake8 and isort
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
2022-09-06 08:07:05 +01:00
Kevin Morris
fbb3e052fe
ci: use cache/virtualenv for test dependencies
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-08-23 02:19:16 -07:00
Kevin Morris
829a8b4b81
Revert "fix(docker): apply chown each time sshd is started"
This reverts commit 952c24783b.

The issue found was actually:
- If `./aur.git` exists within the aurweb repository locally,
  it also ends up in the destination, stopping the aurweb_git_data
  volume from being mounted properly.
2022-08-13 20:56:43 -07:00
Kevin Morris
952c24783b
fix(docker): apply chown each time sshd is started
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-08-13 20:13:07 -07:00
Kevin Morris
f7c81ce855
Revert "docker: simplify keyring update"
This reverts commit 2f294480a9.
2022-01-24 14:54:11 -08:00
Kevin Morris
2f294480a9
docker: simplify keyring update
- this wasn't using .pkg-cache before; we should, in case we already
  have the updated package downloaded.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-23 15:47:31 -08:00
Kevin Morris
7f1de72e08
fix(docker): remove logging setup in run-tests.sh
This was left in when we removed logging.prod.conf in a
previous patch. `test-mysql-entrypoint.sh` takes care of
test logging for us now, so this section is unnecessary.

Closes #261

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-18 05:22:00 -08:00
Kevin Morris
42aa12d075
fix(docker): unrestrict --forwarded-allow-ips on (uvi|hyper)corn
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-15 21:04:47 -08:00
Kevin Morris
b092e247fc
fix(docker): update keyring before installing deps
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-15 20:21:40 -08:00
Kevin Morris
0f4ead759c
fix(docker): correct proxy configuration
- On non-localhost communication, this whitelists forwarded headers
  on all remote ips
- Add more headers
- Force https X-Forwarded-Proto
- Unset Forwarded header and rely on X-Forwarded-*

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-15 20:11:51 -08:00
Kevin Morris
ec3295ffd4
fix(docker): update archlinux-keyring prior to -Syu
When the Docker image is outdated, we need to fetch updated
archlinux-keyring keys to perform an -Syu without problems.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-15 15:18:23 -08:00
Kevin Morris
c4ea1171cd
fix(docker): compile doc during image build
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-13 22:16:17 -08:00
Kevin Morris
9f9b1c1732
change(docker): host fastapi over plain http
We don't need the https certificates being dealt with in the fastapi
service; we will define our certificates in any frontend nginx
running on top.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-10 00:12:01 -08:00
Kevin Morris
a6faf9bd2e
feat(docker): perform migrations when starting the fastapi service
Signed-off-by: Kevin Morris <kevr@0cost.org>
2022-01-06 22:11:03 -08:00
Hunter Wittenborn
2e12417a6c
Added '-x proc' flag to 'crond' command 2021-12-14 17:02:36 -06:00
Kevin Morris
7831503c19
fix(docker): use logging.prod.conf for sharness
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-12-07 15:09:20 -08:00
Kevin Morris
67a6b8360e
fix(docker): remove update and build steps from poetry
`install` includes dependencies present in poetry.lock
and we must stick to them if we wish to pin dependencies.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-28 19:55:12 -08:00
Kevin Morris
0726a08677
fix(docker): remove sqlite scripts
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-27 22:46:11 -08:00
Kevin Morris
b98159d5b9
change(docker): use step-ca for CA + cert generation
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-27 16:43:29 -08:00
Kevin Morris
e891d7c8e8
change(docker): allow run-pytests to collect coverage
Additionally fix up the argument parsing to be a bit less
flexible.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-22 10:22:01 -08:00
Kevin Morris
d4d9f50b8f
change(docker): use ./data instead of ./cache
For the `git` service, ./data is always used to provide an
optional overriding of ssh host keys. In aur-dev production
containers, most services which use the data mount use an
internal Docker `data` volume instead.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-20 20:05:32 -08:00
Kevin Morris
a025118344
change(docker): get python-poetry from arch instead of poetry
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:36:18 -08:00
Kevin Morris
fa26c8078b
fix(docker): modify db configuration for new tests
A user that can create databases is now required for tests,
we use the 'root' user in Docker.

Added docker services:
---------------------
- mariadb_test - host localhost:13307

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-17 01:36:16 -08:00
Kevin Morris
107367f958
feat(docker): use mkpkglists --extended flag
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:29:39 -08:00
Kevin Morris
068b067e14
feat(docker): log cron executions
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 02:28:52 -08:00
Kevin Morris
4b8963b7ba
feat(docker): add cron service (aurblup + mkpkglists)
Normally, these scripts are used to update official providers
in the aurweb database along with archives that can be retrieved.

Run both of these scripts in a 5 minute cron job, to both reflect
the live instance database and production load.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-09 00:29:19 -08:00
Kevin Morris
9aa8decf40
fix(fastapi): use metrics in cases where PROMETHEUS_MULTIPROC_DIR is defined
Previously, we restricted this to gunicorn to get it working on aur-dev.
This change makes it usable through any backend, and also no-op if
PROMETHEUS_MULTIPROC_DIR is not defined.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-01 14:18:19 -07:00
Kevin Morris
cdb854259a
fix(docker): share FASTAPI_BACKEND with the server
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-11-01 13:54:58 -07:00
Kevin Morris
4ae3fbd5d1
change(docker): depend on provided poetry.lock for dep resolution
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-22 17:43:00 -07:00
Kevin Morris
c4163547f6
fix(docker): swap package cgit -> cgit-aurweb
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-21 11:10:55 -07:00
Kevin Morris
927f5e8567
feat(docker): add gunicorn support & production default
Supply FASTAPI_BACKEND=gunicorn and FASTAPI_WORKERS=<threads_num> to
docker-compose up to use the gunicorn backend.

This is defaulted in production to gunicorn, but FASTAPI_WORKERS
should definitely be configured by any production deployment.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-16 22:53:46 -07:00
Kevin Morris
7b7e571e93
change(FastAPI): run test_initdb.py ahead of time in docker
In some cases, when tests fail through Docker, the database
ends up in an invalid state. This causes subsequent runs to
error out with non-sensical DB errors. The `test_initdb.py`
test suite runs tests which setup every modifiable table
in the database, so let's just run it first here to avoid
any invalid test DB state.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-15 20:16:38 -07:00
Kevin Morris
7bfc2bf9b4
fix(FastAPI): Improve sqlite testing speed
This commit adds a new Arch dependency: `libeatmydata`, which
provides the `eatmydata` executable that stubs out fsync() operations.
We use `eatmydata` to run our sharness and pytests in Docker now.

With `autocommit=True`, required by SQLAlchemy to keep the
session up to date with external DB modifications, many fsync
calls are used in the SQLite backend; especially because we're wiping
and creating records in every DB-bound test.

**Before:**

- mysql: 1m42s (elapsed during pytest run)
- sqlite: 3m06s (elapsed during pytest run)

**After:**

- mysql: 1m40s (elapsed during pytest run)
- sqlite: 1m50s (elapsed during pytest run)

Shout out to @klausenbusk, who suggested this as a possible fix,
and it was. Thanks, Kristian!

Closes #120

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-03 15:59:52 -07:00
Kevin Morris
3b1809e2ea
feat(Docker): allow custom certificates for fastapi/nginx
Now, when a `./cache/production.{cert,key}.pem` pair is found, it is
used in place of any certificates generated by the `ca` service.
This allows users to customize the certificate that the FastAPI
ASGI server uses as well as the front-end nginx certificates.

Optional:

- ./cache/production.cert.pem
- ./cache/production.key.pem

Fallback:

- ./cache/localhost.cert.pem + ./cache/root.ca.pem (chain)
- ./cache/localhost.key.pem

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-10-02 13:27:19 -07:00
Kevin Morris
fa07f94051
Docker: Fix FastAPI db initialization
PHP was doing this correctly, but FastAPI was doing this
in it's exec script @ docker/scripts/run-fastapi.sh.

Modify the fastapi service so that it does the same thing as
PHP, and the existing "fastapi restart quirk" is no more.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-04 19:08:10 -07:00
Kevin Morris
2f9994807b
use Poetry to deal with deps and package install
As the new-age Python package manager, Poetry brings a lot
of good additions to the table. It allows us to more easily
deal with virtualenvs for the project and resolve dependencies.

As of this commit, `requirements.txt` is replaced by Poetry,
configured at `pyproject.toml`.

In Docker and GitLab, we currently use Poetry in a root fashion.
We should work toward purely using virtualenvs in Docker, but,
for now we'd like to move forward with other things. The project
can still be installed to a virtualenv and used on a user's system
through Poetry; it is just not yet doing so in Docker.

Modifications:

* docker/scripts/install-deps.sh
    * Remove python dependencies.
* conf/config.defaults
    * Script paths have been updated to use '/usr/bin'.
* docker/git-entrypoint.sh
    * Use '/usr/bin/aurweb-git-auth' instead of
      '/usr/local/bin/aurweb-git-auth'.

Additions:

* docker/scripts/install-python-deps.sh
    * A script used purely to install Python dependencies with Poetry.
      This has to be used within the aurweb project directory and
      requires system-wide dependencies are installed beforehand.
    * Also upgrades system-wide pip.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-04 15:46:40 -07:00
Hunter Wittenborn
eff7d478ab Updated CI tests for pip dependencies; Changed styling in install-deps.sh 2021-08-28 20:12:35 -05:00
Hunter Wittenborn
85b1a05d01 Removed pip dependencies from docker/scripts/install-deps.sh 2021-08-28 19:51:05 -05:00
Kevin Morris
968ed736c1
add python-orjson dependency
python-orjson speeds up a lot of JSON serialization steps,
so we choose to use it over the standard library json module.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-17 19:58:29 -07:00
Kevin Morris
91e769f603
FastAPI: add redis integration
This includes the addition of the python-fakeredis package,
used for stubbing python-redis when a user does not have a
configured cache.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-17 19:58:28 -07:00
Kevin Morris
96d1af9363
docker-compose: add redis service
Now, the fastapi docker-compose service uses the new redis
service for a cache option.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-17 19:58:26 -07:00
Kevin Morris
35851d5533
Docker: add service 'memcached'
Additionally, setup memcached for php-fpm.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-08-16 22:09:09 -07:00
Kevin Morris
8d6e782ba1 add python-feedgen dependency
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-07-01 11:09:09 -07:00
Kevin Morris
3f60f5048e Docker: add scripts/setup-sqlite.sh
This script purely removes any existing sqlite and is
used before tests are run. This causes the test flow
to run `aurweb.initdb` again (if ever).

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 21:53:23 -07:00
Kevin Morris
f4406ccf5c Docker: Centralize repo dependencies
Now, we have `docker/scripts/install-deps.sh`, a script used
by both Docker and .gitlab-ci.yml. We can now focus on changing
deps in this script along as well as documentation going forward.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 21:53:18 -07:00
Kevin Morris
6c7bb04b93 Docker: Improve mariadb init
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-29 21:49:57 -07:00