-
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.
Merge pull request #8 from microsoft/add-pypiserver
Added Pypiserver to coresvc-registry to support airgapped python wheel installations
- Loading branch information
Showing
4 changed files
with
135 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This will start the OCI Registry and the PyPI server in the background and listen for the | ||
# SIGTERM and SIGINT signals to stop the processes gracefully. | ||
|
||
REGISTRY_ENABLED="${REGISTRY_ENABLED:-"true"}" | ||
PYPISERVER_ENABLED="${PYPISERVER_ENABLED:-"true"}" | ||
|
||
# Function to handle termination signal | ||
terminate_processes() { | ||
echo "Termination signal received. Stopping processes..." | ||
if [[ "${REGISTRY_ENABLED}" == "true" ]] && [[ "${PYPISERVER_ENABLED}" == "true" ]]; then | ||
kill $REGISTRY_PID $PYPI_PID | ||
wait $REGISTRY_PID $PYPI_PID | ||
elif [[ "${REGISTRY_ENABLED}" == "true" ]]; then | ||
kill $REGISTRY_PID | ||
wait $REGISTRY_PID | ||
elif [[ "${PYPISERVER_ENABLED}" == "true" ]]; then | ||
kill $PYPI_PID | ||
wait $PYPI_PID | ||
fi | ||
|
||
echo "Processes stopped." | ||
exit 0 | ||
} | ||
|
||
# Trap SIGTERM and SIGINT signals and call the termination function | ||
trap terminate_processes SIGTERM SIGINT | ||
|
||
if [[ "${REGISTRY_ENABLED}" == "true" ]]; then | ||
echo "REGISTRY_ENABLED='true'. Starting the OCI Registry..." | ||
# Run the OCI_Registry in the background | ||
registry serve /etc/docker/registry/config.yml & | ||
REGISTRY_PID=$! | ||
echo "...OCI Registry successfully started." | ||
fi | ||
|
||
if [[ "${PYPISERVER_ENABLED}" == "true" ]]; then | ||
echo "PYPISERVER_ENABLED='true'. Starting the PyPiServer..." | ||
# Run the pypi server in the background | ||
mkdir -p /data/packages | ||
/pypi-server/bin/pypi-server run -p ${PYPISERVER_PORT:-$PORT} --server gunicorn --backend cached-dir /data/packages --verbose --log-file /var/log/pypiserver.log & | ||
PYPI_PID=$! | ||
echo "...PyPiServer started." | ||
fi | ||
|
||
|
||
if [[ "${REGISTRY_ENABLED}" == "true" ]] && [[ "${PYPISERVER_ENABLED}" == "true" ]]; then | ||
# Wait for the background processes to complete | ||
wait $REGISTRY_PID $PYPI_PID | ||
elif [[ "${REGISTRY_ENABLED}" == "true" ]]; then | ||
wait $REGISTRY_PID | ||
elif [[ "${PYPISERVER_ENABLED}" == "true" ]]; then | ||
wait $PYPI_PID | ||
fi | ||
|
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,10 @@ | ||
# Enable to log every request | ||
accesslog = "-" | ||
errorlog = "-" | ||
preload_app = True | ||
workers = 1 | ||
worker_class = "gevent" | ||
|
||
# SSL Certs | ||
keyfile = "/certs/registry.spacefx.local.key" # Path to your private key file | ||
certfile = "/certs/registry.spacefx.local.crt" # Path to your certificate file |