1
0
mirror of https://github.com/quay/quay.git synced 2026-01-27 18:42:52 +03:00
Files
quay/docs/development-container.md
Kurtis Mullins 38be6d05d0 Python 3 (#153)
* Convert all Python2 to Python3 syntax.

* Removes oauth2lib dependency

* Replace mockredis with fakeredis

* byte/str conversions

* Removes nonexisting __nonzero__ in Python3

* Python3 Dockerfile and related

* [PROJQUAY-98] Replace resumablehashlib with rehash

* PROJQUAY-123 - replace gpgme with python3-gpg

* [PROJQUAY-135] Fix unhashable class error

* Update external dependencies for Python 3

- Move github.com/app-registry/appr to github.com/quay/appr
- github.com/coderanger/supervisor-stdout
- github.com/DevTable/container-cloud-config
- Update to latest mockldap with changes applied from coreos/mockldap
- Update dependencies in requirements.txt and requirements-dev.txt

* Default FLOAT_REPR function to str in json encoder and removes keyword assignment

True, False, and str were not keywords in Python2...

* [PROJQUAY-165] Replace package `bencode` with `bencode.py`

- Bencode is not compatible with Python 3.x and is no longer
  maintained. Bencode.py appears to be a drop-in replacement/fork
  that is compatible with Python 3.

* Make sure monkey.patch is called before anything else (

* Removes anunidecode dependency and replaces it with text_unidecode

* Base64 encode/decode pickle dumps/loads when storing value in DB

Base64 encodes/decodes the serialized values when storing them in the
DB. Also make sure to return a Python3 string instead of a Bytes when
coercing for db, otherwise, Postgres' TEXT field will convert it into
a hex representation when storing the value.

* Implement __hash__ on Digest class

In Python 3, if a class defines __eq__() but not __hash__(), its
instances will not be usable as items in hashable collections (e.g sets).

* Remove basestring check

* Fix expected message in credentials tests

* Fix usage of Cryptography.Fernet for Python3 (#219)

- Specifically, this addresses the issue where Byte<->String
  conversions weren't being applied correctly.

* Fix utils

- tar+stream layer format utils
- filelike util

* Fix storage tests

* Fix endpoint tests

* Fix workers tests

* Fix docker's empty layer bytes

* Fix registry tests

* Appr

* Enable CI for Python 3.6

* Skip buildman tests

Skip buildman tests while it's being rewritten to allow ci to pass.

* Install swig for CI

* Update expected exception type in redis validation test

* Fix gpg signing calls

Fix gpg calls for updated gpg wrapper, and add signing tests.

* Convert / to // for Python3 integer division

* WIP: Update buildman to use asyncio instead of trollius.

This dependency is considered deprecated/abandoned and was only
used as an implementation/backport of asyncio on Python 2.x
This is a work in progress, and is included in the PR just to get the
rest of the tests passing. The builder is actually being rewritten.

* Target Python 3.8

* Removes unused files

- Removes unused files that were added accidentally while rebasing
- Small fixes/cleanup
- TODO tasks comments

* Add TODO to verify rehash backward compat with resumablehashlib

* Revert "[PROJQUAY-135] Fix unhashable class error" and implements __hash__ instead.

This reverts commit 735e38e3c1d072bf50ea864bc7e119a55d3a8976.
Instead, defines __hash__ for encryped fields class, using the parent
field's implementation.

* Remove some unused files ad imports

Co-authored-by: Kenny Lee Sin Cheong <kenny.lee@redhat.com>
Co-authored-by: Tom McKay <thomasmckay@redhat.com>
2020-06-05 16:50:13 -04:00

3.8 KiB

Quay Development Container

The instructions below describe how to create and setup a container for working with local source changes and testing. It is meant for a developer familiar with python, javascript, and the tools associated with development.

Quay Source

For convenience, the environment variable QUAY_DEVEL_HOME will be referenced for locations of the parent directory for source and other directories.

The directory $QUAY_DEVEL_HOME/quay is your development git checkout of quay.

cd $QUAY_DEVEL_HOME
git checkout github.com/quay/quay.git

For local storage, create the directory where images will be written to disk.

cd $QUAY_DEVEL_HOME
mkdir quay-storage

The Quay config app should be previously run and the resulting quay-config.tar.gz expanded into place. This file is copied into this directory for convenience only: Keeping it available will allow upload into the config app for modifications later.

cd $QUAY_DEVEL_HOME
mkdir quay-config
cp ~/Downloads/quay-config.tar.gz $QUAY_DEVEL_HOME/quay-config/quay-config.tar.gz
tar xvf $QUAY_DEVEL_HOME/quay-config/quay-config.tar.gz -C $QUAY_DEVEL_HOME/quay-config

Building Development Container

Build an image in a clean git checkout of master branch. It's important not to do this in your own development directory as there may be files that conflict or break a clean build.

cd $QUAY_DEVEL_HOME/quay
docker build -t quay:devel -f Dockerfile .

Run Development Container

Note: Assumptions are that the config app has successfully run and database is available. This can be done via regular user documentation and using the quay:devel image built above.

docker run --rm --name quay \
    -v $QUAY_DEVEL_HOME/quay-config:/conf/stack \
    -v $QUAY_DEVEL_HOME/quay-storage:/datastorage \
    -v $QUAY_DEVEL_HOME/quay:$QUAY_DEVEL_HOME/quay \
    -p 8080:8080 \
    -p 8443:8443 \
    -p 9092:9092 \
    -e QUAY_DEVEL_HOME=$QUAY_DEVEL_HOME \
    quay:devel

This will start the quay container and be fully running. The web UI is available at port 8443.

Switch Services to Development

Inside the Container

When exec'ing into the development container, it is best to run under the SCLs used during production. This will provide the correct paths to python and other executables.

docker exec --rm -it quay bash

The following sections are perhaps easiest to run in separate docker exec sessions, which is how they will be described. Some or all could be run in the background and managed differently than described here.

Stop Services

When running the quay container, all regular services are started by default. In order to run a service locally, stopping the default is important. Below are the steps for developing the web UI and web backend python service.

Stop services:

supervisorctl -c /quay-registry/conf/supervisord.conf stop gunicorn-web

Change the web resources to devel location:

cd /quay-registry
mv static static.bak
ln -s $QUAY_DEVEL_HOME/quay/static

Build web assets:

cd $QUAY_DEVEL_HOME/quay
mkdir -p static/webfonts
mkdir -p static/fonts
mkdir -p static/ldn
PYTHONPATH=. python -m external_libraries

yarn build

Run Migrations

If $QUAY_DEVEL_HOME/quay, which presumably has your local code changes, has migrations, special care should be taken when switching between different versions of code.

To run a migration:

cd $QUAY_DEVEL_HOME/quay
PYTHONPATH=. alembic upgrade 5248ddf35167

To revert a migration:

cd $QUAY_DEVEL_HOME/quay
PYTHONPATH=. alembic downgrade -1

Web UI Assets

cd $QUAY_DEVEL_HOME/quay
yarn build && npm run watch

Run Web Server

cd $QUAY_DEVEL_HOME/quay
PYTHONPATH=. gunicorn -c conf/gunicorn_web.py web:application