xtract-container-service
This is the repository for the Xtract Container Service (XCS), an application for pushing and pulling Docker and Singularity containers.
Getting started for development
These instructions will get the XCS application running on your local machine for development and testing purposes.
Prerequisites
- Docker (available here)
- Singularity (available here)
- AWS CLI (available here)
- AWS RDS, S3, SQS
- PostgreSQL
Installation
-
Clone this repository and activate a virtual environment:
git clone https://github.com/xtracthub/xtract-container-service cd xtract-container-service virtualenv venv source venv/bin/activate
-
Install the requirements:
pip install -r requirements.txt
Setting up AWS
-
Configure your AWS CLI:
aws configure
-
Next, create a PostgreSQL database in AWS RDS and store the following in a file named
database.ini
:[postgresql] host=YOUR_HOST_ADRESS database=postgres user=postgres password=YOUR_PASSWORD
-
Create an AWS S3 bucket and a SQS queue named
xtract-container-service
:
Running XCS
-
Save your Globus Auth. Client ID and Client Secret as environment variables:
export GL_CLIENT=YOUR_GL_CLIENT export GL_CLIENT_SECRET=YOUR_GL_CLIENT_SECRET
-
Save the path of the flask app. as an environment variable:
export FLASK_APP=application.py
-
Start the application with root privelages:
sudo flask run
-
Ensure the Docker daemon is running using
sudo dockerd
for Ubuntu or starting Docker Desktop for Mac.
Getting started for production
These instructions will get the XCS application running on Ubuntu for production.
Prerequisites
- Docker (available here)
- Singularity (available here)
- AWS CLI (available here)
- AWS RDS, S3, SQS
- PostgreSQL
- Python3
Installation and Configuration
-
Install Apache:
sudo apt install apache2 libapache2-mod-wsgi-py3
-
Clone this repository and activate a virtual environment:
git clone https://github.com/xtracthub/xtract-container-service cd xtract-container-service virtualenv venv source venv/bin/activate
-
Configure the AWS CLI:
aws configure
-
Create a symbolic link to the
/var/www/html/flaskapp
folder:sudo ln -sT ~/xtract-container-service /var/www/html/flaskapp
-
In
flaskapp.wsgi
, set your Globus Auth and AWS credentials. -
In
/etc/apache2/sites-enabled/000-default.conf
, add the following after theDocumentRoot /var/www/html
line:WSGIDaemonProcess flaskapp threads=5 python-path=/var/www/html/flaskapp/venv/lib/python3.6/site-packages WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi WSGIPassAuthorization On <Directory flaskapp> WSGIProcessGroup flaskapp WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory>
-
Allow Apache to run Docker as a non-root user:
sudo groupadd docker sudo usermod -aG docker www-data sudo newgrp docker
-
Restart Apache:
sudo service apache2 restart
Running XCS
-
In one terminal, ensure that Docker is stopped and start the Docker daemon:
sudo systemctl stop docker sudo dockerd
Interacting with the server
XCS is a REST API so all interactions can be made with Python's request library. Examples of how to make requests can be found in app_demo.ipynb
(New SDK coming soon)