-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Remote Build Plugin #269
base: master
Are you sure you want to change the base?
Changes from 21 commits
9fcb172
1d76319
fc8bf63
8c18269
654dfbf
7e93573
fe6f7f1
518f744
68814a0
742acf3
f3f7301
f08dc5e
7614d5a
08d172f
f689b1c
1252814
dcd62a6
0213c38
ae61077
0332e53
c86b97c
38aabc9
d323fc7
53c2b67
53bc0bb
9be73af
2526290
b110667
24c2b52
0034198
072dee3
50cc60c
2f47616
f526870
137c576
edcf1fb
0543380
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
title: "Plugin: Custom Builder and Storage" | ||
pdf: true | ||
toc: true | ||
permalink: docs/plugins/remote-build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this require a permalink, and if so, should it end in trailing slash? |
||
--- | ||
|
||
# Plugin: Remote Build mimic sylabs API | ||
|
||
## Configure sregistry | ||
|
||
By default, remote build is disabled. To configure sregistry to | ||
use Google Cloud build and Storage, in settings/config.py you can enable the plugin by | ||
uncommenting it from the list here: | ||
|
||
```bash | ||
PLUGINS_ENABLED = [ | ||
# 'ldap_auth', | ||
# 'saml_auth', | ||
# 'globus', | ||
# 'google_build', | ||
'remote_build' | ||
] | ||
``` | ||
You will need to build the image locally with, at least, the build argument ENABLE_REMOTEBUILD set to true: | ||
|
||
```bash | ||
$ docker build --build-arg ENABLE_REMOTEBUILD=true -t quay.io/quay.io/vanessa/sregistry . | ||
``` | ||
|
||
## Secrets | ||
|
||
Next, set the following variables in `shub/settings/secrets.py`, | ||
that you can create from `dummy_secrets.py` in the shub/settings folder. | ||
The first two speak for themselves, your project name and path to your | ||
Google Application Credentials. | ||
|
||
## Singularity Remote Build | ||
|
||
This is a first effort to provide support to `remote build`. | ||
Freshly build image on application server (aka `worker`) is then pushed on library... | ||
So we need [singularity client](https://sylabs.io) installed on application server. | ||
|
||
### Motivation | ||
|
||
Remote build provide user without local compute resource (for instance), | ||
to build remotely and retrieved locally container image on their desktop. | ||
|
||
It's also a way to share quickly conitainer image. | ||
|
||
You can proceed through [googlebuild](https://singularityhub.github.io/sregistry/docs/plugins/google-build) plugin, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. google-build |
||
but it's not everyone that have the opportunity to access google cloud, for security reason for instance... | ||
|
||
### In the nutshell | ||
|
||
This basic implementation of the Sylabs Library API use django | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Django |
||
[channels](https://channels.readthedocs.io/en/latest/) Websocket Server | ||
[Daphne](https://github.com/django/daphne/) and [ASGI](https://channels.readthedocs.io/en/latest/asgi.html) | ||
|
||
### Requisite | ||
|
||
This is the same than for [Singularity Push](#singularity-push) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you mean Prerequisite, and that it's "the same implementation as is used for pushing a Singularity image" or something like that. This sentence doesn't make sense. |
||
|
||
### Install | ||
|
||
You need to build new locally image, with new argument ENABLE_REMOTEBUILD set to true: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about at the end I'll just go through this and update the language, I understand English isn't your first language, and the important thing for now is that I understand it :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll fix all these typos issues. Is quiet late at France and i'll continue later.... Enjoy these holiday periods and meet up later, probably next year ;-) ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought this over, and don't worry about the typos / imperfect English - if you get the main points across I should be able to help out with the English bits before it's ready for merge. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha, or... in the next decade!! 💥 |
||
|
||
``` | ||
docker build --build-arg ENABLE_REMOTEBUILD=true -t quay.io/quay.io/vanessa/sregistry . | ||
kamedodji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### Utilisation | ||
|
||
To build remotely image on [sregistry](https://singularityhub.github.io/sregistry): | ||
|
||
``` | ||
singularity build --builder https://127.0.0.1 --remote <image name> <spec file> | ||
``` | ||
|
||
Container image `<image name>` will then be generate locally and on remote library. | ||
|
||
To generate image only remotely, use: | ||
|
||
``` | ||
singularity build --builder https://127.0.0.1 --detached <spec file> | ||
``` | ||
|
||
### Features | ||
|
||
- [X] build on remote library | ||
- [X] retrieve locally build | ||
- [ ] implement `WYSIWYG` via web interface through popular [django-ace](https://github.com/django-ace/django-ace) | ||
vsoch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### TODO :boom: | ||
|
||
- [ ] Automatically create collection `remote-builds` | ||
- [ ] Re-use Django Push View in Build View | ||
- [ ] Optimize channels consumer `BuildConsumer` | ||
- [ ] Extend collection spacename to username | ||
- [ ] Dedicated worker for build | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These as well. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
upstream websocket { | ||
ip_hash; | ||
server 172.17.0.6:3032 fail_timeout=0; | ||
} | ||
|
||
server { | ||
listen *:80; | ||
server_name localhost; | ||
|
||
client_max_body_size 10024M; | ||
client_body_buffer_size 10024M; | ||
client_body_timeout 120; | ||
|
||
add_header X-Clacks-Overhead "GNU Terry Pratchett"; | ||
add_header X-Clacks-Overhead "GNU Terry Pratchet"; | ||
add_header Access-Control-Allow-Origin *; | ||
add_header 'Access-Control-Allow-Credentials' 'true'; | ||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; | ||
add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; | ||
|
||
location /images { | ||
alias /var/www/images; | ||
} | ||
|
||
location ~* \.(php|aspx|myadmin|asp)$ { | ||
deny all; | ||
} | ||
|
||
location / { | ||
include /etc/nginx/uwsgi_params.par; | ||
uwsgi_pass uwsgi:3031; | ||
uwsgi_max_temp_file_size 10024m; | ||
} | ||
|
||
location /static { | ||
alias /var/www/static; | ||
} | ||
|
||
# Upload form should be submitted to this location | ||
location /upload { | ||
|
||
# Pass altered request body to this location | ||
upload_pass /api/uploads/complete/; | ||
|
||
# Store files to this directory | ||
# The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist | ||
upload_store /var/www/images/_upload 1; | ||
upload_store_access user:rw group:rw all:rw; | ||
|
||
# Set specified fields in request body | ||
upload_set_form_field $upload_field_name.name "$upload_file_name"; | ||
upload_set_form_field $upload_field_name.content_type "$upload_content_type"; | ||
upload_set_form_field $upload_field_name.path "$upload_tmp_path"; | ||
|
||
# Inform backend about hash and size of a file | ||
upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5"; | ||
upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size"; | ||
|
||
upload_pass_form_field "^submit$|^description$"; | ||
upload_pass_form_field "^SREGISTRY_EVENT$"; | ||
upload_pass_form_field "^collection$"; | ||
upload_pass_form_field "^name$"; | ||
upload_pass_form_field "^tag$"; | ||
upload_cleanup 400-599; | ||
|
||
} | ||
|
||
location /v1/build-ws/ { | ||
proxy_pass http://websocket; # daphne (ASGI) listening on port 3032 | ||
proxy_http_version 1.1; | ||
proxy_read_timeout 86400; | ||
proxy_redirect off; | ||
|
||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Host $server_name; | ||
} | ||
} | ||
|
||
server { | ||
|
||
listen 443; | ||
server_name localhost; | ||
|
||
root html; | ||
client_max_body_size 10024M; | ||
client_body_buffer_size 10024M; | ||
|
||
ssl on; | ||
ssl_certificate /etc/ssl/certs/chained.pem; | ||
ssl_certificate_key /etc/ssl/private/domain.key; | ||
ssl_session_timeout 5m; | ||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | ||
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA; | ||
ssl_session_cache shared:SSL:50m; | ||
ssl_dhparam /etc/ssl/certs/dhparam.pem; | ||
ssl_prefer_server_ciphers on; | ||
|
||
location /images { | ||
alias /var/www/images; | ||
} | ||
|
||
location /static { | ||
alias /var/www/static; | ||
} | ||
|
||
location ~* \.(php|aspx|myadmin|asp)$ { | ||
deny all; | ||
} | ||
|
||
# Upload form should be submitted to this location | ||
location /upload { | ||
|
||
# Pass altered request body to this location | ||
upload_pass /api/uploads/complete/; | ||
|
||
# Store files to this directory | ||
# The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist | ||
upload_store /var/www/images/_upload 1; | ||
upload_store_access user:rw group:rw all:rw; | ||
|
||
# Set specified fields in request body | ||
upload_set_form_field $upload_field_name.name "$upload_file_name"; | ||
upload_set_form_field $upload_field_name.content_type "$upload_content_type"; | ||
upload_set_form_field $upload_field_name.path "$upload_tmp_path"; | ||
|
||
# Inform backend about hash and size of a file | ||
upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5"; | ||
upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size"; | ||
|
||
upload_pass_form_field "^submit$|^description$"; | ||
upload_pass_form_field "^SREGISTRY_EVENT$"; | ||
upload_pass_form_field "^collection$"; | ||
upload_pass_form_field "^name$"; | ||
upload_pass_form_field "^tag$"; | ||
upload_cleanup 400-599; | ||
|
||
} | ||
|
||
location / { | ||
include /etc/nginx/uwsgi_params.par; | ||
uwsgi_pass uwsgi:3031; | ||
uwsgi_max_temp_file_size 10024m; | ||
} | ||
|
||
location /v1/build-ws/ { | ||
proxy_pass http://websocket; # daphne (ASGI) listening on port 3032 | ||
proxy_http_version 1.1; | ||
proxy_read_timeout 86400; | ||
proxy_redirect off; | ||
|
||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Host $server_name; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't change the permalink here - I'm guessing you haven't written the docs? I'll need complete docs (including a link to the build server to set up first) to walk through and test your plugin.