mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
container: distribution as environment variable
Allow distribution to be passed as an environment variable. Fixes #1914 Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
4b0899fd65
commit
1fca2465aa
23
HACKING.md
23
HACKING.md
@ -83,6 +83,29 @@ development environment inside a systemd-nspawn container.
|
|||||||
host$ ./container ssh
|
host$ ./container ssh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
6. The default distribution used by the container script is "testing", but you
|
||||||
|
can choose a different distribution (e.g. "stable") in two ways.
|
||||||
|
|
||||||
|
1. Using an environment variable.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
host$ DISTRIBUTION=stable ./container up
|
||||||
|
host$ DISTRIBUTION=stable ./container ssh
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
host$ export DISTRIBUTION=stable
|
||||||
|
host$ ./container up
|
||||||
|
host$ ./container ssh
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Using the `--distribution` option for each command.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
host$ ./container up --distribution=stable
|
||||||
|
host$ ./container ssh --distribution=stable
|
||||||
|
```
|
||||||
|
|
||||||
#### Using after Setup
|
#### Using after Setup
|
||||||
|
|
||||||
After logging into the container, the source code is available in `/freedombox`
|
After logging into the container, the source code is available in `/freedombox`
|
||||||
|
|||||||
20
container
20
container
@ -261,10 +261,16 @@ def parse_arguments():
|
|||||||
|
|
||||||
distributions = list(URLS.keys())
|
distributions = list(URLS.keys())
|
||||||
|
|
||||||
|
distribution = os.environ.get('DISTRIBUTION')
|
||||||
|
|
||||||
|
default_distribution = 'testing'
|
||||||
|
if distribution and distribution in distributions:
|
||||||
|
default_distribution = distribution
|
||||||
|
|
||||||
# Up
|
# Up
|
||||||
subparser = subparsers.add_parser('up', help='Bring up the container')
|
subparser = subparsers.add_parser('up', help='Bring up the container')
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'--distribution', choices=distributions, default='testing',
|
'--distribution', choices=distributions, default=default_distribution,
|
||||||
help='Distribution of the image to download and setup')
|
help='Distribution of the image to download and setup')
|
||||||
subparser.add_argument('--image-size', default='16G',
|
subparser.add_argument('--image-size', default='16G',
|
||||||
help='Disk image size to resize to after download')
|
help='Disk image size to resize to after download')
|
||||||
@ -273,20 +279,20 @@ def parse_arguments():
|
|||||||
subparser = subparsers.add_parser(
|
subparser = subparsers.add_parser(
|
||||||
'ip', help='Print the IP address of the container.')
|
'ip', help='Print the IP address of the container.')
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'--distribution', choices=distributions, default='testing',
|
'--distribution', choices=distributions, default=default_distribution,
|
||||||
help='Distribution of the container to print IP address')
|
help='Distribution of the container to print IP address')
|
||||||
|
|
||||||
# ssh
|
# ssh
|
||||||
subparser = subparsers.add_parser('ssh', help='SSH into the container')
|
subparser = subparsers.add_parser('ssh', help='SSH into the container')
|
||||||
subparser.add_argument('--distribution', choices=distributions,
|
subparser.add_argument('--distribution', choices=distributions,
|
||||||
default='testing',
|
default=default_distribution,
|
||||||
help='Distribution of the container to SSH into')
|
help='Distribution of the container to SSH into')
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
subparser = subparsers.add_parser('run-tests',
|
subparser = subparsers.add_parser('run-tests',
|
||||||
help='Run tests in the container')
|
help='Run tests in the container')
|
||||||
subparser.add_argument('--distribution', choices=distributions,
|
subparser.add_argument('--distribution', choices=distributions,
|
||||||
default='testing',
|
default=default_distribution,
|
||||||
help='Distribution of the container to run tests')
|
help='Distribution of the container to run tests')
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'--pytest-args', nargs='...',
|
'--pytest-args', nargs='...',
|
||||||
@ -295,21 +301,21 @@ def parse_arguments():
|
|||||||
# Stop
|
# Stop
|
||||||
subparser = subparsers.add_parser('stop', help='Stop the container')
|
subparser = subparsers.add_parser('stop', help='Stop the container')
|
||||||
subparser.add_argument('--distribution', choices=distributions,
|
subparser.add_argument('--distribution', choices=distributions,
|
||||||
default='testing',
|
default=default_distribution,
|
||||||
help='Distribution of the container to stop')
|
help='Distribution of the container to stop')
|
||||||
|
|
||||||
# Destroy
|
# Destroy
|
||||||
subparser = subparsers.add_parser('destroy',
|
subparser = subparsers.add_parser('destroy',
|
||||||
help='Destroy the container image')
|
help='Destroy the container image')
|
||||||
subparser.add_argument('--distribution', choices=distributions,
|
subparser.add_argument('--distribution', choices=distributions,
|
||||||
default='testing',
|
default=default_distribution,
|
||||||
help='Distribution of the image to delete')
|
help='Distribution of the image to delete')
|
||||||
|
|
||||||
# Update
|
# Update
|
||||||
subparser = subparsers.add_parser(
|
subparser = subparsers.add_parser(
|
||||||
'update', help='Update the container image to the latest version')
|
'update', help='Update the container image to the latest version')
|
||||||
subparser.add_argument('--distribution', choices=distributions,
|
subparser.add_argument('--distribution', choices=distributions,
|
||||||
default='testing',
|
default=default_distribution,
|
||||||
help='Distribution of the image to update')
|
help='Distribution of the image to update')
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user