Skip to content
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

add: remote builder defs #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions remote-builder/nginx-php/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Nginx & PHP

1. Build the container via the Sylabs Remote Builder

2. Pull container from the library
```sh
singularity pull nginx.sif library://<cloud-image-path>
```

3. Start the container image.
```sh
sudo singularity instance start --writable-tmpfs --net --network bridge --network-args "portmap=8080:80/tcp" nginx.sif nginx
```

4. Access the nginx container running on port 8080
```sh
$ curl -i localhost:8080/index.php

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Date: Mon, 07 Jun 2021 15:45:43 GMT
Server: nginx/1.21.0
Transfer-Encoding: chunked
X-Powered-By: PHP/8.0.6

<h1>Hello from php and nginx in a sif</h1>
```
60 changes: 60 additions & 0 deletions remote-builder/nginx-php/nginx.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Bootstrap: docker
From: nginx:alpine

%setup

cat > /tmp/default.conf <<EOF
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;

root /var/www/html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;

index index.php index.html index.htm index.nginx-debian.html;

location / {
try_files $uri $uri/index.php =404;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}

location ~ /\.(?!well-known).* {
deny all;
}
}
EOF

cat > /tmp/index.php <<EOF
<?='<h1>Hello from php and nginx in a sif</h1>'; ?>
EOF

cat > /tmp/php.conf <<EOF
[www]
user = www
group = www
listen = 127.0.0.1:9000
EOF

%files
/tmp/default.conf /etc/nginx/conf.d/default.conf
/tmp/index.php /var/www/html/index.php
/tmp/php.conf /etc/php8/php-fpm.d/php.conf

%startscript
php-fpm8 -D
nginx -g "daemon off;"

%post
apk update
apk add ca-certificates wget openssl curl
update-ca-certificates
apk add php8-fpm php8-cli php8-mysqli php8-pdo php8-pdo_mysql
ln -s /usr/bin/php8 /usr/bin/php
mkdir -p /var/www/html
28 changes: 28 additions & 0 deletions remote-builder/nodejs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Node.js

[Node.js](https://nodejs.org/en/) is a JavaScript runtime built on Chrome's V8 JavaScript engine.

A quick run through follows:
1. Build the container via the Sylabs Remote Builder
2. Pull the container with:
```sh
singularity pull node.sif library://<cloud-image-path>
```
3. Run the container as an instance:
```sh
singularity instance start node.sif node
```
4. Access the web-server via curl
```sh
$ curl -i localhost:4000

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 12
Date: Mon, 07 Jun 2021 15:26:29 GMT
Connection: keep-alive
Keep-Alive: timeout=5

Hello World!
```
47 changes: 47 additions & 0 deletions remote-builder/nodejs/nodejs.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Bootstrap: docker
From: node:16-alpine

%setup
mkdir -p ${SINGULARITY_ROOTFS}/usr/local/share/node/app
mkdir -p app
cat > app/index.js <<EOF
const express = require("express");
const app = express();
const port = 4000;

app.get("/", (req, res) => {
res.send("Hello World!");
});

app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
EOF

cat > app/package.json <<EOF
{
"name": "node",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"express": "^4.17.1"
}
}
EOF

%files
app /usr/local/share/node

%startscript
node /usr/local/share/node/app/index.js

%post
mkdir -p /usr/local/share/node/app/
cd /usr/local/share/node/app/
yarn