2016-06-17 22:07:33 +00:00
# quay
2018-06-05 18:35:23 +00:00
[![Build Status ](https://travis-ci.com/quay/quay.svg?token=pWvEz2TeyDsVn69Hkiwq&branch=master )](https://travis-ci.com/quay/quay)
2016-06-17 22:07:33 +00:00
![Docker Repository on Quay ](https://quay.io/repository/quay/quay/status?token=7bffbc13-8bb0-4fb4-8a70-684a0cf485d3 "Docker Repository on Quay" )
2016-12-27 21:54:53 +00:00
:warning: The `master` branch may be in an *unstable or even broken state* during development.
2016-06-17 22:07:33 +00:00
Please use [releases] instead of the `master` branch in order to get stable binaries.
2016-06-17 22:15:37 +00:00
![Quay Logo ](static/img/quay_preview.png )
2016-06-17 22:07:33 +00:00
Quay is project to build, store, and distribute container images.
High-level features include:
2016-08-04 02:18:09 +00:00
- Docker Registry Protocol [v1], [v2]
- Docker Manifest Schema [v2.1]
- [AppC Image Discovery] via on-demand transcoding
- Image Squashing via on-demand transcoding
2016-06-17 22:07:33 +00:00
- Authentication provided by [LDAP], [Keystone], [Dex], [Google], [GitHub]
- ACLs, team management, and auditability logs
- Geo-replicated storage provided by local filesystems, [S3], [GCS], [Swift], [Ceph]
- Continuous Integration integrated with [GitHub], [Bitbucket], [GitLab], and [git]
- Security Vulnerability Analysis via [Clair]
- [Swagger]-compliant HTTP API
[releases]: https://github.com/coreos-inc/quay/releases
2016-08-04 02:18:09 +00:00
[v1]: https://docs.docker.com/v1.6/reference/api/registry_api/
[v2]: https://docs.docker.com/v1.6/registry/
[v2.1]: https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-1.md
2016-06-17 22:07:33 +00:00
[AppC Image Discovery]: https://github.com/appc/spec/blob/master/spec/discovery.md
[LDAP]: https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol
[Keystone]: http://docs.openstack.org/developer/keystone
[Dex]: https://github.com/coreos/dex
[Google]: https://developers.google.com/identity/sign-in/web/sign-in
[GitHub]: https://developer.github.com/v3/oauth
[S3]: https://aws.amazon.com/s3
[GCS]: https://cloud.google.com/storage
[Swift]: http://swift.openstack.org
[Ceph]: http://docs.ceph.com/docs/master/radosgw/config
[GitHub]: https://github.com
[Bitbucket]: https://bitbucket.com
[GitLab]: https://gitlab.com
[git]: https://git-scm.com
[Clair]: https://github.com/coreos/clair
[Swagger]: http://swagger.io
2016-12-27 21:39:30 +00:00
## Table of Contents
1. ** [Getting Started ](#getting-started )**
1. [macOS ](#macos )
3. [Linux ](#linux )
2. ** [Development ](#development )**
1. [PivotalTracker Integration ](#pivotaltracker-integration )
3. ** [Running and Testing ](#running-and-testing )**
1. [Test Data ](#test-data )
2. [Local Scripts ](#local-scripts )
3. [Development inside Docker ](#development-inside-docker )
4. [Adding a Python Dependency ](#adding-a-python-dependency )
2017-06-14 21:43:59 +00:00
5. [Adding a Yarn Dependency ](#adding-a-yarn-dependency )
6. [Running the Build System ](#running-the-build-system )
7. [To run individual tests ](#to-run-individual-tests )
2016-12-27 21:39:30 +00:00
1. [Pytest ](#pytest )
2. [Tox ](#tox )
2017-06-14 21:43:59 +00:00
8. [Running Migrations ](#running-migrations )
9. [How to run a build with tests for a push or merge ](#how-to-run-a-build-with-tests-for-a-push-or-merge )
2016-12-27 21:39:30 +00:00
4. ** [Documentation ](#documentation )**
1. [Architecture at a Glance ](#architecture-at-a-glance )
2. [Terminology ](#terminology )
1. [Organizations ](#organizations )
2. [Concepts ](#concepts )
3. [Software ](#software )
2016-06-17 22:07:33 +00:00
## Getting Started
### macOS
macOS developers will need:
* [command line tools] or [xcode]
* [brew]
[command line tools]: https://developer.apple.com/downloads
[xcode]: https://developer.apple.com/downloads
[brew]: https://github.com/Homebrew/brew
2018-01-25 20:18:43 +00:00
[docker]: https://www.docker.com/docker-mac
2014-05-27 19:19:23 +00:00
2017-01-23 20:44:53 +00:00
```sh
2016-06-17 22:07:33 +00:00
# Download the code
git clone git@github.com:coreos-inc/quay.git & & cd quay
2015-08-21 20:40:41 +00:00
2016-06-17 22:07:33 +00:00
# Install the system dependencies
2018-01-25 20:18:43 +00:00
brew install libevent libmagic postgresql gpgme pyenv pyenv-virtualenv node yarn
2016-10-06 14:43:25 +00:00
2017-01-23 20:44:53 +00:00
# Create a default virtualmachine for docker
2016-10-06 14:43:25 +00:00
docker-machine create -d virtualbox default
2017-01-23 20:44:53 +00:00
# Add these to ~/.bashrc or ~/.zshrc
2016-10-06 14:43:25 +00:00
eval "$(pyenv virtualenv-init -)"
eval "$(pyenv init -)"
eval $(/usr/local/bin/docker-machine env default)
2017-07-11 14:25:05 +00:00
export PYTHONPATH="."
2014-05-27 19:19:23 +00:00
2016-06-17 22:07:33 +00:00
# Some installs don't have /usr/include, required for finding SASL header files
2017-01-23 20:44:53 +00:00
# This command might fail because of the rootfs is read-only. Refer to the following:
2016-10-06 14:43:25 +00:00
# http://apple.stackexchange.com/questions/196224/unix-ln-s-command-not-permitted-in-osx-el-capitan-beta3
2016-06-17 22:07:33 +00:00
if [ ! -e /usr/include ]; then sudo ln -s `xcrun --show-sdk-path` /usr/include /usr/include; fi
2013-10-11 04:57:27 +00:00
2016-06-17 22:07:33 +00:00
# Install the Python dependencies
2017-01-23 20:44:53 +00:00
pyenv install 2.7.12
pyenv virtualenv 2.7.12 quay
2016-06-17 22:07:33 +00:00
pyenv activate quay
2017-01-23 20:44:53 +00:00
pyenv local quay
2016-10-06 14:56:58 +00:00
# Some packages may fail to build with clang (which now defaults to C11).
2017-01-23 20:44:53 +00:00
# If you're getting errors trying running again with CFLAGS='std=c99'.
pip install -r requirements.txt
2016-06-17 22:07:33 +00:00
pip install -r requirements-dev.txt
2017-01-23 20:44:53 +00:00
pip install -r requirements-test.txt
2013-10-02 20:42:12 +00:00
2016-06-17 22:07:33 +00:00
# Setup a local config
git clone git@github.com:coreos-inc/quay-config.git ../quay-config
ln -s ../../quay-config/local conf/stack
2016-09-27 18:06:28 +00:00
# Install Node Dependencies
2017-02-28 03:37:12 +00:00
yarn install
2016-09-27 18:06:28 +00:00
# Link Typescript
2017-02-28 03:37:12 +00:00
yarn link typescript
2016-06-17 22:07:33 +00:00
```
2015-08-18 17:47:16 +00:00
2017-01-23 20:44:53 +00:00
#### Third Party Docs
2016-10-06 15:02:58 +00:00
2017-01-23 20:44:53 +00:00
* [docker ](https://beta.docker.com/docs/mac/getting-started )
* [docker-machine ](https://docs.docker.com/machine/install-machine )
2016-12-27 21:54:53 +00:00
* [pyenv ](https://github.com/yyuu/pyenv )
* [pyenv-virtualenv ](https://github.com/yyuu/pyenv-virtualenv )
2016-10-06 15:02:58 +00:00
2018-01-30 18:44:04 +00:00
### Docker Compose
2015-08-18 17:47:16 +00:00
2018-01-30 18:44:04 +00:00
You'll need Docker and [Docker Compose ](https://docs.docker.com/compose ) installed.
If you're on macOS, [Docker for Mac ](https://www.docker.com/docker-mac ) should include
both tools. Otherwise, follow the docs for your platform.
2016-06-17 22:07:33 +00:00
2018-01-30 18:44:04 +00:00
You'll also need Node.js and NPM if you want to interact with the
frontend code outside a container.
2016-12-27 21:39:30 +00:00
2018-01-30 18:44:04 +00:00
Finally, you'll need a recent [Go ](https://golang.org ) version for the
builder.
2016-12-27 21:27:22 +00:00
2018-01-30 18:44:04 +00:00
To start Quay locally:
```sh
# Clone the various repos you'll need:
git clone https://github.com/coreos-inc/quay.git
git clone https://github.com/coreos-inc/quay-config-local.git
git clone https://github.com/coreos-inc/quay-builder.git
2016-12-27 21:27:22 +00:00
2018-01-30 18:44:04 +00:00
# Build the builder:
cd quay-builder
make build GOOS=linux
2016-12-27 21:27:22 +00:00
2018-01-30 18:44:04 +00:00
# Install NPM modules:
cd ../quay
npm install
# Build or pull images and start all Quay components:
docker-compose up
2016-12-27 21:27:22 +00:00
```
2018-01-30 18:44:04 +00:00
#### Third Party Docs
* [Docker Compose ](https://docs.docker.com/compose )
* [Docker for Mac ](https://www.docker.com/docker-mac )
### Linux
Do you use Linux? Send us a PR! Or use docker-compose!
## Development
### JIRA
2016-12-27 21:27:22 +00:00
2018-01-30 18:44:04 +00:00
The Quay backlog can be found in JIRA: https://jira.coreos.com/projects/QUAY
2016-12-27 21:27:22 +00:00
2016-06-17 22:07:33 +00:00
## Running and Testing
### Test Data
2016-12-27 21:54:53 +00:00
A SQLite database full of test data is committed to this git repository at [test/data/test.db ](quay/test/data/test.db ).
2016-06-17 22:07:33 +00:00
This database is generated by executing `python initdb.py` .
2016-06-17 22:23:11 +00:00
The username and password of the admin test account is `devtable` and `password` , respectively.
2015-08-18 17:47:16 +00:00
2016-06-17 22:07:33 +00:00
### Local Scripts
2016-10-19 16:43:30 +00:00
Running the web server locally requires [goreman ](https://github.com/mattn/goreman ):
2016-12-27 21:54:53 +00:00
2017-01-23 20:44:53 +00:00
```sh
2016-10-19 16:43:30 +00:00
go get github.com/mattn/goreman
```
2016-06-17 22:07:33 +00:00
* `local-run` runs the web server for testing
* `local-test` runs the unit test suite
2017-02-28 03:37:12 +00:00
* `yarn run build` builds front-end dependencies
* `yarn run watch` builds and watches front-end dependencies
* `yarn test` runs front-end test suite
2016-06-17 22:07:33 +00:00
### Development inside Docker
2016-12-27 21:54:53 +00:00
To build and run a development container, pass one argument to [local-docker.sh ](quay/local-docker.sh ):
2015-08-18 17:47:16 +00:00
- `buildman` : run the buildmanager
2016-06-17 22:07:33 +00:00
- `dev` : run web server on port 5000
2015-10-06 05:29:15 +00:00
- `initdb` : clear and initialize the test database
2016-06-17 22:07:33 +00:00
- `notifications` : run the notification worker
- `test` : run the unit test suite
2015-08-18 17:47:16 +00:00
2016-06-17 22:07:33 +00:00
### Adding a Python Dependency
2015-08-18 17:47:16 +00:00
2017-01-23 20:44:53 +00:00
```sh
2016-06-17 22:07:33 +00:00
# Create a new virtualenv and activate it
2017-01-23 22:57:11 +00:00
pyenv virtualenv 2.7.12 quay-deps
2016-06-17 22:07:33 +00:00
pyenv activate quay-deps
2015-08-18 17:47:16 +00:00
2016-06-17 22:07:33 +00:00
# Install unversioned dependencies with your changes
pip install -r requirements-nover.txt
2015-08-18 17:47:16 +00:00
2016-06-17 22:07:33 +00:00
# Run the unit test suite
./local-test.sh
2014-05-27 19:19:23 +00:00
2016-06-17 22:07:33 +00:00
# Freeze the versions of all of the dependencies
pip freeze > requirements.txt
2017-01-23 20:44:53 +00:00
# Delete the virtualenv
pyenv uninstall quay-deps
2014-02-01 00:21:05 +00:00
```
2017-06-14 21:43:59 +00:00
### Adding a Yarn Dependency
We use [Yarn ](https://yarnpkg.com/ ) for frontend dependency management. The `yarn.lock` file ensures
that we get consistant version installs using the `yarn install` command. However, new dependencies
should be added using `yarn add <npm package>` . This will add an entry to `package.json` and `yarn.lock` .
Occassionally there will be merge conflicts with `yarn.lock` . To resolve them, use the following (taken
2017-07-11 14:25:05 +00:00
from [here ](https://github.com/yarnpkg/yarn/issues/1776#issuecomment-269539948 )).
2017-06-14 21:43:59 +00:00
```sh
git rebase origin/master
git checkout origin/master -- yarn.lock
yarn install
git add yarn.lock
git rebase --continue
```
2016-06-17 22:07:33 +00:00
### Running the Build System
TODO
2014-02-26 18:45:49 +00:00
2017-01-23 20:44:53 +00:00
```sh
2016-06-17 22:07:33 +00:00
# Run an instance of redis
docker run -d -p 6379:6379 quay.io/quay/redis
2014-02-26 18:45:49 +00:00
```
2016-10-07 14:19:03 +00:00
### To run individual tests
2017-01-23 20:44:53 +00:00
```sh
2016-10-07 14:19:03 +00:00
# To run a specific suite
TEST=true python -m test.test_api_usage -f
# To run a specific test in a suite
TEST=true python -m test.test_api_usage -f SuiteName
```
2016-11-24 14:18:22 +00:00
#### Pytest
2016-10-07 14:19:03 +00:00
2017-01-23 20:44:53 +00:00
```sh
2016-11-24 14:18:22 +00:00
# To run all tests
2016-12-20 19:01:06 +00:00
TEST=true PYTHONPATH="." py.test --verbose
2016-11-24 14:18:22 +00:00
# To run a specific test module
2018-05-01 10:52:35 +00:00
TEST=true PYTHONPATH="." py.test --verbose test/registry/registry_tests.py
2016-11-24 14:18:22 +00:00
# To run a specific test unique test
TEST=true PYTHONPATH="." py.test --verbose test/test_api_usage.py::TestDeleteNamespace
# To retry only last failed (--lf):
TEST=true PYTHONPATH="." py.test --verbose --lf
# To start pdb on failure:
TEST=true PYTHONPATH="." py.test --verbose --pdb
# To run a coverage report (html pages in ./htmlcov):
TEST=true PYTHONPATH="." py.test --cov="." --cov-report=html --cov-report=term-missing --cov-config=.coverage.ini --verbose
# Don't capture stdout (-s)
TEST=true PYTHONPATH="." py.test --verbose -s
```
#### Tox
2017-01-23 20:44:53 +00:00
2016-11-24 14:18:22 +00:00
To create a virtualenv to run the tests.
It allows to test the code on multiple env like python2.x and python3.x or different library versions
2017-01-23 20:44:53 +00:00
```sh
2016-11-24 14:18:22 +00:00
# Test all tox env:
tox
# Add extra parameters to the pytest command:
# tox -- [pytest ARGS]
tox -- -x
# build a single env with -e:
tox -e py27-api
```
2016-10-07 18:20:00 +00:00
### Running migrations
2017-01-23 20:44:53 +00:00
```sh
2016-10-07 18:20:00 +00:00
# To create a new migration with this description.
# Note there might be some errors about unique id being to long
# That's okay as long as the migration file is created
./data/migrations/migration.sh "Description goes here"
# To test the up and down of the migration
./data/migrations/migration.sh # without params
2016-10-10 16:26:44 +00:00
# Migrations get run when you create a docker image or you can run them
# manually with the following command.
PYTHONPATH=. alembic upgrade head
2016-10-11 14:23:18 +00:00
# You can also rebuild your local sqlite db image from initdb.py using
2016-11-24 14:18:22 +00:00
# And once you have a migration you should do this and check in the
2016-10-11 19:09:38 +00:00
# changes to share your migration with others.
2016-10-11 14:23:18 +00:00
rm test/data/test.db
python initdb.py
2016-10-07 18:20:00 +00:00
```
2016-10-26 15:26:54 +00:00
2017-01-18 21:16:45 +00:00
### Running tests for migrations
Use AWS/RDS to create a test image.
2017-01-23 20:44:53 +00:00
To create a new database from a snapshot to test against see
2017-01-18 21:16:45 +00:00
[this ](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_RestoreFromSnapshot.html ).
2017-01-23 20:44:53 +00:00
Then point the migrations to the new instance using
2017-01-18 21:16:45 +00:00
quay-config/local/config.yaml
Remember to run this from the root of the quay directory and to set your
python environment first.
2017-01-23 20:44:53 +00:00
```sh
2017-01-18 21:16:45 +00:00
PYTHONPATH=. alembic upgrade head
```
2016-10-26 15:26:54 +00:00
### How to run a build with tests for a push or merge
2017-01-23 20:44:53 +00:00
```sh
2016-10-26 15:26:54 +00:00
# Inside the quay directory.
export QUAY_TAG=quay.io/quay/quay:localtest
docker build -t $QUAY_TAG --build-arg RUN_TESTS=true .
```
2016-06-17 22:07:33 +00:00
## Documentation
2016-04-05 18:18:01 +00:00
2016-06-17 22:07:33 +00:00
* [Quay Enterprise Documentation ](https://tectonic.com/quay-enterprise/docs/latest )
* [Quay.io Documentation ](https://docs.quay.io )
2016-04-05 18:18:01 +00:00
2016-12-27 21:54:53 +00:00
### Architecture at a Glance
< img src = "https://docs.google.com/a/coreos.com/drawings/d/1J-YZs7aun1lLy-1wFwIZcBma5IJmZQ8WfgtEftHCKJ0/pub?w=640&h=480" >
Edit chart on Google Docs at [Architecture at a Glance ](https://docs.google.com/a/coreos.com/drawings/d/1J-YZs7aun1lLy-1wFwIZcBma5IJmZQ8WfgtEftHCKJ0/edit?usp=sharing ).
2016-06-17 22:07:33 +00:00
### Terminology
2016-04-06 17:52:42 +00:00
2016-08-04 02:09:22 +00:00
#### Organizations
- **AppC**: a standards body responsible for a _Runtime_ and _Image Format_ superseded by the _Open Container Initiative_
- **Open Container Initiative**: a standards body responsible for a _Runtime_ specification and an _Image Format_
- **Docker**: a company that builds a platform that has its own _Image Formats_ , _Build System_ , _Container Runtime_ , and _Container Orchestration_
#### Concepts
- **Image**: an archive containing all of the contents necessary to execute a container
- **Image Format**: a specification for the structure of an _Image_
- **Image Layer**: an _Image_ that may depend on being applied to other _Images_ to generate a final _Image_
- **Image Squashing**: the process of compressing an _Image_ into a single _Layer_
- **Manifest**: a text file containing metadata for a particular _Image_
- **Tag**: a human-friendly named, mutable pointer to a particular set of _Images_
- **Build System**: a program used to generate _Images_
- **Registry**: a program that speaks one or more standard protocols to store and receive _Images_
- **Repository**: a collection of related _Tags_ organized by a _Registry_
- **Push**: the act of uploading an _Image_ to a _Registry_
- **Pull**: the act of downloading an _Image_ from a _Registry_
- **Container**: an _Image_ and its execution environment
- **Container Runtime**: a program that can transform an _Image_ into a _Container_ by executing it
- **Container Orchestration**: a program or set of programs that provides a framework for deploying _Containers_
#### Software
- **Quay.io**: CoreOS's hosted _Registry_
- **Quay**: CoreOS's enterprise-grade _Registry_ product
- **quayctl**: an open source program that implements alternative methods for _pulling_ _Images_ from _Quay_
- **Clair**: an open source static analysis tool used to detect vulnerability in _Images_
- **Quay Security Scanning**: the integration between _Clair_ and _Quay_
- **Kubernetes**: an open source program implementing _Container Orchestration_
- **Docker Hub**: Docker's hosted _Registry_
- **Docker Trusted Registry**: Docker's enterprise-grade _Registry_ product
- **Notary**: an open source implementation of the TUF protocol used in _Docker Content Trust_
2016-08-04 02:18:09 +00:00
- **Docker Content Trust**: the integration between _Notary_ and _Docker Trusted Registry_
2016-08-04 02:09:22 +00:00
- **Docker Engine**: a program used to interact with all aspects of the Docker platform
- **Swarm**: a program implementing _Container Orchestration_ for the Docker platform