Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
16 changes: 10 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
version: 2.1

# https://circleci.com/orbs/registry/orb/singularity/singularity
# defaults to golang 1.13 and singularity 3.5.0
# defaults to golang 1.17.1 and singularity 3.8.2
orbs:
singularity: singularity/singularity@1.0.10

singularity: singularity/singularity@1.0.11

################################################################################
# Workflows
Expand All @@ -19,6 +18,11 @@ workflows:
branches:
ignore: master

executors:
ubuntu-machine:
machine:
image: ubuntu-2004:202107-02

################################################################################
# Functions
################################################################################
Expand Down Expand Up @@ -57,22 +61,22 @@ install_dependencies: &install_dependencies
[ $(python -c'import sys;print(sys.version_info.major)') -eq $PYTHON_VERSION ]
pip install --upgrade pytest setuptools


################################################################################
# Jobs
################################################################################

jobs:
run-scompose-ci-tests:
machine: true
executor: "ubuntu-machine"
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys: v3-dependencies
- run: *install_dependencies
- singularity/install-go
- singularity/debian-install-3
- singularity/debian-install-3:
singularity-version: 3.8.3
- save_cache:
paths:
- ~/conda
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
The versions coincide with releases on pypi.

## [0.0.x](https://github.com/singularityhub/singularity-compose/tree/master) (0.0.x)
- add network->allocate_ip option on composer file (0.1.1)
- version 2.0 of the spec with added fakeroot network, start, exec, and run options (0.1.0)
- stop option added (equivalent functionality to down)
- spython version 0.1.0 with Singularity 3.x or greater required
Expand Down
19 changes: 19 additions & 0 deletions docs/spec/spec-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ network configuration at `/usr/local/etc/singularity/network/40_fakeroot.conflis
If you don't want to make these changes, then you won't be able to use fakeroot
as a network (start) option (you might still be able to use it as a build option).

## Network Group

By default `singularity-compose` will allocate an IP address for every instance in
the listed yaml file. Binding an IP address to a process requires `sudo` so in certain
scenarios in which access to a privileged user isn't an option, you might want to tell
`singularity-compose` not to allocate an IP address, that way you can run instances
without `sudo`.

The example below will run a container that exposes the port `5432` to the host.

```yaml
instance1:
...
network:
allocate_ip: true | false
ports:
- 5432:5432
```

## Start Group

Startscript options generally include those for networking, and any other flags
Expand Down
22 changes: 11 additions & 11 deletions scompose/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,27 +227,27 @@ def show_help(return_code=0):

# Does the user want a shell?
if args.command == "build":
from .build import main
from scompose.client.build import main
elif args.command == "create":
from .create import main
from scompose.client.create import main
elif args.command == "config":
from .config import main
from scompose.client.config import main
elif args.command in ["down", "stop"]:
from .down import main
from scompose.client.down import main
elif args.command == "exec":
from .exec import main
from scompose.client.exec import main
elif args.command == "logs":
from .logs import main
from scompose.client.logs import main
elif args.command == "ps":
from .ps import main
from scompose.client.ps import main
elif args.command == "restart":
from .restart import main
from scompose.client.restart import main
elif args.command == "run":
from .run import main
from scompose.client.run import main
elif args.command == "shell":
from .shell import main
from scompose.client.shell import main
elif args.command == "up":
from .up import main
from scompose.client.up import main

# Pass on to the correct parser
return_code = 0
Expand Down
13 changes: 11 additions & 2 deletions scompose/project/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, name, working_dir, sudo=False, params=None):

self.set_context(params)
self.set_volumes(params)
self.set_network(params)
self.set_ports(params)
self.params = params
self.client = get_client()
Expand Down Expand Up @@ -143,6 +144,14 @@ def set_volumes_from(self, instances):
if volume not in self.volumes:
self.volumes.append(volume)

def set_network(self, params):
"""set network from the recipe to be used"""
self.network = params.get("network", {})

# if not specified, set the default value for allocate_ip property
if "allocate_ip" not in self.network:
self.network["allocate_ip"] = True

def set_ports(self, params):
"""set ports from the recipe to be used"""
self.ports = params.get("ports", [])
Expand Down Expand Up @@ -197,7 +206,7 @@ def _get_network_commands(self, ip_address=None):
ports += ["--network-args", '"portmap=%s/tcp"' % pair]

# Ask for a custom ip address
if ip_address is not None:
if ip_address is not None and self.network["allocate_ip"]:
ports += ["--network-args", '"IP=%s"' % ip_address]

return ports
Expand Down Expand Up @@ -496,7 +505,7 @@ def logs(self, tail=0):

# Create and Delete

def up(self, working_dir, ip_address=None, sudo=False, writable_tmpfs=False):
def up(self, working_dir, ip_address=None, writable_tmpfs=False):
"""up is the same as create, but like Docker, we build / pull instances
first.
"""
Expand Down
4 changes: 2 additions & 2 deletions scompose/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ def create(
return self._create(names, writable_tmpfs=writable_tmpfs, no_resolv=no_resolv)

def up(
self, names=None, writable_tmpfs=True, bridge="10.22.0.0/16", no_resolv=False
self, names=None, writable_tmpfs=True, bridge="10.22.0.0/16", no_resolv=False,
):

"""call the up function, instance.up(), which will build before if
a container binary does not exist.
"""
return self._create(
names, command="up", writable_tmpfs=writable_tmpfs, no_resolv=no_resolv
names, command="up", writable_tmpfs=writable_tmpfs, no_resolv=no_resolv,
)

def _create(
Expand Down
2 changes: 1 addition & 1 deletion scompose/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_commands(tmp_path):
run_command(["git", "clone", repo, tmpdir])

# Test the simple apache example
workdir = os.path.join(tmpdir, "apache-simple")
workdir = os.path.join(tmpdir, "v1.0", "apache-simple")
os.chdir(workdir)

# Check for required files
Expand Down
2 changes: 1 addition & 1 deletion scompose/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"""

__version__ = "0.1.0"
__version__ = "0.1.1"
AUTHOR = "Vanessa Sochat"
AUTHOR_EMAIL = "vsochat@stanford.edu"
NAME = "singularity-compose"
Expand Down