153 Commits

Author SHA1 Message Date
e9b103eb23 release v0.1.10 2021-12-11 02:02:59 +02:00
bbaa786739 Fixes #199: seccomp:unconfined 2021-12-11 02:02:09 +02:00
d1d0f9e452 FIXES #371: respect COMPOSE_FILE env 2021-12-11 02:02:00 +02:00
d8dba61e08 FIXES #185: creates dirs 2021-12-11 02:01:44 +02:00
3343910763 resolve 2021-12-11 02:01:19 +02:00
34ec4b3cb9 #222: normalize basedir using os.path.realpath 2021-12-11 01:54:22 +02:00
f4a78ae812 FIXES #333: when volumes are merged, remove duplicates 2021-12-11 01:54:09 +02:00
00b9ce1ee4 FIXES #368: parse depends_on of type dict 2021-12-11 01:53:27 +02:00
749d188321 fix AttributeError when running a one-off command
Without this, I get errors when running "podman-compose -p podname run".
2021-12-04 00:47:09 +02:00
e879529976 Remove named volumes during "down -v"
Fixes containers#105

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
2021-11-23 08:02:10 +02:00
1555417958 FIXES #361: key error _service 2021-11-21 15:55:19 +02:00
1f989ed133 FIXES #356: respect pull_policy 2021-11-16 11:12:08 +02:00
66ce2a34f5 release 0.1.8 2021-11-15 00:27:03 +02:00
d8e11d59ef FIXES #312: run starts dependencies 2021-11-14 01:37:22 +02:00
72c3572123 #289: exit code and test for that 2021-11-14 00:59:41 +02:00
c187e88eaf up and down specific containers 2021-11-14 00:28:43 +02:00
31b8bb477d simpler passing of env 2021-11-14 00:00:08 +02:00
f177712585 Fix up arguments parsing
These is already parsed here
502d7cc206/podman_compose.py (L1644)
2021-11-13 23:53:57 +02:00
ae3deb19dc #355: fix dry run 2021-11-13 13:08:32 +02:00
117b7fbb9e command list of strings 2021-11-11 17:52:02 +02:00
5acb9978eb command list of strings 2021-11-11 17:47:26 +02:00
02b2f6585d Update issue templates 2021-11-11 17:43:47 +02:00
a36b6f1feb Update issue templates 2021-11-11 17:16:47 +02:00
e3be6dd511 Update issue templates 2021-11-11 17:13:56 +02:00
4b756786f3 Update issue templates 2021-11-11 17:12:02 +02:00
dcb038ef3a remove tabs 2021-11-11 14:27:30 +02:00
a2fef56b07 FIXES #353: down in reverse order 2021-11-11 11:32:24 +02:00
c753b8e2cf FIXES #167: support ContainerFile 2021-11-11 11:27:33 +02:00
c9486c9f3b #115: handle string entrypoint 2021-10-25 00:14:19 +03:00
f2aeaba0d6 #348: conditional --infra-name 2021-10-24 17:35:36 +03:00
2d80e435dd remove print 2021-10-14 02:12:28 +03:00
d1a77defcd external name 2021-10-14 02:11:45 +03:00
c49f0700c8 volumes with names 2021-10-14 01:30:44 +03:00
6d69b7c74c Add support external volumes
# docker-compose.yml
version: '3'
services:
  test:
     volumes:
        - data:/data
volumes:
  data:
     name: some
     external: true
2021-10-14 00:12:06 +03:00
ab135030c8 add support for long port publishing format 2021-10-10 00:43:01 +03:00
069018c5b1 #342: set infra container name 2021-10-04 14:40:54 +03:00
b33c42b7e2 Readability fix for missing commands
Of course it would be better to have a proper compatibility page (#26)
2021-09-23 14:58:45 +03:00
785f7ad8a3 Get version info with setup.cfg 2021-09-11 23:35:36 +03:00
b6a9f8efd4 #335: report version with -v 2021-09-09 00:33:07 +03:00
4a5fd23a2e #275 make pipx happy 2021-09-08 14:23:02 +03:00
Sam
dc0ac0d03c docs: added the transform_policy default and description 2021-09-06 10:02:13 +03:00
502d7cc206 #327: accept ports as string 2021-08-26 12:37:14 +03:00
e85d79d4f4 added cpu_shares flag for v2 2021-08-18 11:56:12 +03:00
bfb57b9ba2 added cpu_shares flag for v2 2021-08-18 11:56:12 +03:00
2d0aad6692 Also pull images with a build section 2021-08-05 15:07:05 +03:00
ff5b9f1663 Support for logging 2021-07-27 14:54:36 +03:00
Sam
62aa337f17 feat(secrets): Add support for secrets
Adds support for -
- (1) Declared secrets with the file location.
- (2) Declared secrets with file location, mounted as a different named secret.
- (3) Declared secrets with file location, mounted at arbitrary location.
- (4) External secrets (type=mount), mounted as original secret name.
- (5) External secrets (type=mount), mounted as original secret name, with specified uid, gid and mode.
2021-07-24 02:29:32 +03:00
3836094c64 Update podman_compose.py
it would be nice to use "podman-compose.yml" as a compose file name. compose.yml is useful, but I prefer the clarity of having the "podman" prefix.
2021-07-17 16:18:40 +03:00
d97a20d563 #308: fix environment 2021-06-23 18:04:13 +03:00
f417c9ab8c #120: extend not add 2021-06-22 23:52:24 +03:00
5ed5528294 FIXES #120: parse mem and cpu limits 2021-06-22 23:48:05 +03:00
3d6ca3c204 FIXES #120: parse mem and cpu limits 2021-06-22 23:30:22 +03:00
6e3383de72 Convert numeric command arguments to string (fixes #77)
The input argument cmd_args is a list which may contain numeric elements.

Convert all elements to strings before passing them to functions which
expect str data type.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-06-16 22:19:42 +03:00
8ef7587aa1 Fix some typos (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-06-16 22:17:28 +03:00
039fe30a70 Make sure port entries are converted to strings
Otherwise concatenating all parameters might fail with a TypeError
2021-05-28 21:10:55 +03:00
62d2024fee Add stop_signal service attribute 2021-05-18 22:14:21 +03:00
9317f987fc #278: args 2021-05-17 15:03:47 +03:00
045cef299b #289: report exit code when --exit-code-from 2021-05-06 02:08:48 +03:00
a7f97b6120 implement -e in run 2021-05-06 01:17:01 +03:00
0ea18b4419 Force adding an .env file for the tests 2021-05-06 00:50:41 +03:00
905914b0dc Merge branch 'garotosopa-devel' into devel 2021-05-06 00:49:54 +03:00
00840d0613 resolve conflict 2021-05-06 00:49:42 +03:00
2ad7daa81f Test variable interpolation in the YAML 2021-05-06 00:44:46 +03:00
080b8a369e Prefer 'compose.yaml' as per compose spec
https://github.com/compose-spec/compose-spec/blob/master/spec.md#compose-file
2021-05-05 17:32:25 +03:00
226ac4fb3a fix missing --label flag in volume creation 2021-05-05 02:13:42 +03:00
030a196102 Fix README typo 2021-04-29 19:20:47 +03:00
901213e5b3 Update podman_compose.py
repair mode written as size
2021-04-29 19:20:26 +03:00
b3370603d9 Add support for sysctls in compose file 2021-04-29 19:19:42 +03:00
b3090c3c3a Mode Python installation and test deps to requirement files
Installation with setup.py fails on missing yaml package, which should
be installed by "install_requires" but this also does not work because
podman_compose.__version__ also needs yaml.
Put all the Python dependencies into separate files:
    - requirements.txt
    - test-requirements.txt
2021-04-29 19:19:14 +03:00
5fabfee497 Support annotations
Support annotations analog to "security opt" in commit 29e2bf4c.

Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
2021-04-29 19:18:29 +03:00
75a63df954 fix: check .env in current dir with isfile instead of exists
This prevents cases in which an `.env` directory exists, for example
in Python projects with a local virtual environment, and then
dotenv gets passed the directory path as input.
2021-04-29 19:18:06 +03:00
08dd36f4c1 Add docker-compose labels for interoperability 2021-04-29 19:17:20 +03:00
669953b3d3 Rework argument generation to adhere directly to what podman accepts. 2021-04-29 19:10:55 +03:00
d3df688aee Remove test code 2021-04-29 19:10:55 +03:00
bda7b5e812 Add exec support 2021-04-29 19:10:55 +03:00
6289d25a42 fixes #236: compatible with docker-compose 2020-12-02 15:31:51 +02:00
abc08135ba Only pull each image once 2020-11-27 18:09:58 +02:00
9cd837f01d Fixes #236: Ensure project name works with podman
In case we use dir_basename as podman project name, ensure it matches
podman project name requirement regex: [a-zA-Z0-9][a-zA-Z0-9_.-]*
2020-11-19 17:52:49 +02:00
a4b8b5e709 Fix 'podman-compose version' with no compose file in the working directory
Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
2020-11-19 14:51:06 +02:00
5971f57130 FIXES #249: update dotenv with some envs 2020-11-05 00:14:57 +02:00
ab96f12dba FIXES #249: update dotenv with some envs 2020-11-05 00:08:19 +02:00
f6a3cb0aff Allow environment variables to be unset
Leaving keys with empty values in YAML will result in the value
ending up being None after parsing the configuration file. This
should result in the variable being imported from the external
environment according to the Compose file version 3 reference.
The resulting action for podman should be an added "-e VAR"
(without =), which is working correctly.

However, when overwriting an external variable by setting it to
e.g. "", the result in docker-compose is that the variable is
unset. For podman, this means adding "-e VAR=". This is not the
case, and this patch does a more strict check to make this case
behave correctly.
2020-10-12 12:45:14 +03:00
497355fcfb Re-order environment/env_files to match compose
docker-compose reads the 'env_files' and adds the content as
environment values before adding the 'environment' data. This
means that that 'environment' data overrides 'env_files' data.
Emulate this behaviour by re-ordering -e statements to end up
after --env-file statements.

Relevant function in docker-compose can be viewed here:
https://github.com/docker/compose/blob/1.27.4/compose/config/config.py#L694-L697
2020-10-08 23:25:52 +03:00
20a86ea563 add --no-cache arg to build 2020-09-27 14:14:55 +03:00
4e2e960106 build specific service 2020-09-27 14:14:55 +03:00
efba3a1380 support str style configuration for env_file 2020-09-10 00:59:51 +03:00
90639769f0 BUG: 'podman stop -t 360.0' called for float, expects int on cli 2020-09-06 12:22:01 +03:00
3712b545a9 ENH: add timeout option to podman-compose down, as in https://docs.docker.com/compose/reference/down/ 2020-09-06 12:22:01 +03:00
294f8ee37b Hashlib to generate SHA256 instead of MD5 for FIPS
Changed hashlib to generate a SHA256 instead of MD5 in order for
podman-compose to function on systems with FIPS mode enabled.
2020-06-15 22:44:00 +03:00
105b129b08 Fix infinite loop
Since we never remove thread from the list of thread, podman-compose
up never return as long as 1 thread is alive.
2020-06-02 23:14:59 +03:00
d3f37112a7 FIXES #181: accept init and init-path 2020-05-22 23:52:48 +03:00
7eacf14693 MAINT: resolve https://github.com/containers/podman-compose/pull/180#issuecomment-632722974 2020-05-22 18:09:25 +03:00
8cd98ab708 MAINT: extend instead of append 2020-05-22 18:09:25 +03:00
047820dbf1 ENH: Added restart policy forwarding to podmann run, compose build args added to up args 2020-05-22 18:09:25 +03:00
e7b1382b1b Add --build-arg to 'up' (Fixes #161) 2020-05-22 17:06:38 +03:00
64ed554543 Allow empty default/error value in substitution 2020-05-13 17:54:20 +03:00
0ac75fd361 Merge pull request #172 from TomSweeneyRedHat/sec1
Add Security Policy
2020-05-11 10:59:07 -04:00
93bf39e9e2 Add Security Policy
As the title says, plus a small fix in the readme.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-05-09 17:54:44 -04:00
5915ba345f Catch error when compose file is empty
Also catch cases such as the top element being a list or a string
2020-05-09 20:04:52 +03:00
1ca6a88ebd target once 2020-04-22 14:44:36 +03:00
7b40079c06 Pass "target" parameter when building an image. 2020-04-22 14:42:32 +03:00
f9915c47b4 Check for target property when building images
For multi-stage builds, this allows picking a stage to build up to
2020-04-22 14:36:35 +03:00
19733407b4 Add support for --build-arg option 2020-04-22 14:31:00 +03:00
e8147e350b Add support for cap_add/cap_drop
Currently, `cap_add` and `cap_drop` are being ignored by podman-compose.
Add the arguments (`--cap-add` and `--cap-drop`, respectively) to
`podman create` when appropriate.
2020-04-22 14:27:33 +03:00
7f210ffc43 fixing "Error: unknown flag: --shm_size" 2020-04-21 17:12:11 +03:00
cbed801c0d start detached 2020-04-19 03:53:55 +03:00
6a42d6861d add ports test 2020-04-18 22:41:06 +03:00
07a2430c41 Fixes #152: validate that podman is useable 2020-04-18 22:18:36 +03:00
5215782cba Fixes #152: validate that podman is useable 2020-04-18 22:15:55 +03:00
80e7ba188d resolve 2020-04-18 18:46:23 +03:00
03cbd2929b pass volumes using -v 2020-04-18 18:39:59 +03:00
796e6a4473 Avoid crash when no services are defined
If no services are defined, podman-compose
crashes as services variable is None,
while the expected behavior might be
an error or the same as docker-compose, which will continue the
execution of the compose file (eg. creating networks, etc).

This commit fixes the crash and allows the program to continue, mimicking
docker-compose behavior.
2020-04-05 10:42:31 +03:00
efcbc75f63 Pass ulimit parameters when building container
When running podman-compose build, pass ulimit arguments from
docker-compose.yml through to podman build.
2020-02-27 17:39:33 +02:00
dacc7538ec Add Code of Conduct
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-02-09 01:23:49 +02:00
8c3b7e6c54 Added mount option delegated and cached 2019-11-24 10:18:15 +02:00
147f0ae42f Update README with dnf install instructions. 2019-11-24 10:17:23 +02:00
27d3cafb7b Add support for privileged option
Adds support for the `privileged` option in docker-compose.yml. This has
been supported in docker-compose since 0.4.0, so it seems reasonable to
add support here.

See https://docs.docker.com/compose/compose-file/#domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir
2019-11-17 13:13:03 +02:00
e7a9bd3b70 Show stopped containers in ps 2019-11-10 17:16:02 +02:00
ddd582c861 Add support for logs subcommand 2019-11-10 17:15:36 +02:00
169eaee9b2 Fix override of the run command
If there's no command defined in the arguments, `podman-compose run`
should use the command defined in docker-compose.yml
2019-11-10 17:03:17 +02:00
c5f8973bd5 Mixed-case directory names break 'podman create'
The default project_name uses the directory name, but 'podman create' fails if the directory is mixed case.
2019-11-10 17:02:43 +02:00
12036aa54e FIXES #76: a service extends a service with same name 2019-11-07 19:09:32 +02:00
0fc864ffbe Merge branch 'devel' of github.com:containers/podman-compose into devel 2019-11-07 18:56:00 +02:00
7222fdb6e7 exit if not files 2019-11-07 18:55:49 +02:00
bb7120f3ff Fix stop command runs start instead 2019-10-26 20:45:19 +02:00
7ebbe2efc6 Fix KeyErrors encountered with extended services
Docker compose file used:
https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/master/view/lib/wikibase-tainted-ref/docker-compose.yml
2019-10-25 16:09:38 +02:00
29d4cdc9ab Remove unused funtion in setup.py
Signed-off-by: William José Moreno Reyes <williamjmorenor@gmail.com>
2019-10-13 00:31:50 +03:00
a9216c3980 podman volume inspect mountPoint/Mountpoint
podman version 1.6.1 volume inspect outputs Mountpoint instead of mountPoint
2019-10-05 23:44:38 +03:00
e538852dbe #57: better ps via label 2019-10-05 22:47:04 +03:00
b1c2b0222b podman_compose.py 2019-10-05 22:38:50 +03:00
9e0dd2da9d extends with external file 2019-10-05 22:37:14 +03:00
72c1992737 Remove never-shared options. 2019-10-05 22:35:05 +03:00
3e2381f040 Support extends
https://docs.docker.com/compose/extends/

Doesn't yet support referring to another file.

Needs Python 3.5+ (for merging dicts using **)
2019-10-05 22:35:05 +03:00
dee813a4b6 #47: version command 2019-10-04 20:57:07 +03:00
9684429157 #52: fix how we split commands 2019-10-04 20:36:30 +03:00
87e7211ade #54: fix ulimits 2019-10-04 20:27:19 +03:00
72697016f9 Fixed get of ulimit tag, according to docker-compose specification 2019-10-04 20:24:36 +03:00
b369073574 Fix podman-compose run command parsing
This got confused with the main command (up, down, …),
thus leading to:

    cmd = self.commands[cmd_name]
TypeError: unhashable type: 'list'
2019-10-01 13:26:38 +03:00
62f0cc492c Changed -l flag to --label in order to be compatible with Podman 1.0.2.dev 2019-10-01 13:25:01 +03:00
c152d28af7 Support for generic container-compose format 2019-09-20 23:33:59 +03:00
8e43e69c5b FIX #41: compare original volume name 2019-09-14 00:32:00 +03:00
4c07e875a0 Merge branch 'devel' of github.com:containers/podman-compose into devel 2019-09-13 22:25:52 +03:00
751aaa87f6 Add support for devices in a service 2019-09-13 22:25:26 +03:00
243bdb688d Add support for setting container ulimit
- supports `ulimit: host` or other single value
- As well as `ulimit: [nofile=5000, nproc=5000]` array
- As well as `ulimit: {nofile: 5000, nproc: 5000}` dict

Authored-by: Tyler Ramer <tramer@pivotal.io>
2019-09-13 22:25:26 +03:00
d9cd0d6186 Merge branch 'master' of github.com:containers/podman-compose into devel 2019-09-13 22:23:22 +03:00
ec06da2265 Merge pull request #38 from tylarb/ulimit
Add support for setting container ulimit
2019-09-12 02:00:23 +03:00
2202e7f39b Add support for setting container ulimit
- supports `ulimit: host` or other single value
- As well as `ulimit: [nofile=5000, nproc=5000]` array
- As well as `ulimit: {nofile: 5000, nproc: 5000}` dict

Authored-by: Tyler Ramer <tramer@pivotal.io>
2019-09-11 18:12:29 -04:00
f505e499a2 a test showing yaml anchor magic 2019-09-09 00:48:25 +03:00
813dc8b149 Merge remote-tracking branch 'origin/master' into devel 2019-09-09 00:18:41 +03:00
6f2e5de57c Merge pull request #37 from thenomemac/patch-3
add string check for cmd line args
2019-09-08 20:17:13 +03:00
2e4378f7ad add string check for cmd line args 2019-09-08 12:57:49 -04:00
2a8d430c92 FIXES #35: now support multiple composer files 2019-09-08 02:20:48 +03:00
a512c0cb82 #35: test for multiple -f 2019-09-04 16:12:13 +03:00
50 changed files with 1581 additions and 293 deletions

54
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,54 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
Please make sure it's not a bug in podman (in that case report it to podman)
or your understanding of docker-compose or how rootless containers work (for example, it's normal for rootless container not to be able to listen for port less than 1024 like 80)
please try to reproduce the bug in latest devel branch
**To Reproduce**
Steps to reproduce the behavior:
1. what is the content of the current working directory (ex. `docker-compose.yml`, `.env`, `Dockerfile`, ...etc.)
2. what is the sequence of commands you typed
please use [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) for example give me a small busybox-based compose yaml
**Expected behavior**
A clear and concise description of what you expected to happen.
**Actual behavior**
What is the behavior you actually got and that should not happen.
**Output**
```
$ podman-compose version
using podman version: 3.4.0
podman-composer version 0.1.7dev
podman --version
podman version 3.4.0
$ podman-compose up
...
```
**Environment:**
- OS: Linux / WSL / Mac
- podman version:
- podman compose version: (git hex)
**Additional context**
Add any other context about the problem here.

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

3
CODE-OF-CONDUCT.md Normal file
View File

@ -0,0 +1,3 @@
## The Podman Compose Project Community Code of Conduct
The Podman Compose project follows the [Containers Community Code of Conduct](https://github.com/containers/common/blob/master/CODE-OF-CONDUCT.md).

View File

@ -54,12 +54,11 @@ def compose_up(compose, args):
## Missing Commands (help needed)
```
bundle Generate a Docker bundle from the Compose file
config Validate and view the Compose file
create Create services
events Receive real time events from containers
exec Execute a command in a running container
images List images
kill Kill containers
logs View output from containers
@ -72,3 +71,4 @@ def compose_up(compose, args):
top Display the running processes
unpause Unpause services
version Show the Docker-Compose version information
```

View File

@ -1,15 +1,24 @@
# Podman Compose
An implementation of `docker-compose` with [podman](https://podman.io/) backend.
An implementation of `docker-compose` with [Podman](https://podman.io/) backend.
The main objective of this project is to be able to run `docker-compose.yml` unmodified and rootless.
This project is aimed to provide drop-in replacement for `docker-compose`,
and it's very useful for certain cases because:
- can run rootless
- only depend on `podman` and Python3 and [PyYAML](https://pyyaml.org/)
- no daemon, no setup.
- can be used by developers to run single-machine containerized stacks using single familiar YAML file
This project only depend on:
* `podman`
* Python3
* [PyYAML](https://pyyaml.org/)
* [python-dotenv](https://pypi.org/project/python-dotenv/)
And it's formed as a single python file script that you can drop into your PATH and run.
For production-like single-machine containerized environment consider
- [k3s](https://k3s.io) | [k3s github](https://github.com/rancher/k3s)
@ -20,9 +29,12 @@ For production-like single-machine containerized environment consider
For the real thing (multi-node clusters) check any production
OpenShift/Kubernetes distribution like [OKD](https://www.okd.io/minishift/).
## NOTE
## Versions
This project is still underdevelopment.
If you have legacy version of `podman` (before 3.x) you might need to stick with legacy `podman-compose` `0.1.x` branch.
The legacy branch 0.1.x uses mappings and workarounds to compensate for rootless limitations.
Modern podman versions (>=3.4) do not have those limitations and thus you can use latest and stable 1.x branch.
## Installation
@ -54,6 +66,12 @@ curl -o ~/.local/bin/podman-compose https://raw.githubusercontent.com/containers
chmod +x ~/.local/bin/podman-compose
```
or install from Fedora (starting from f31) repositories:
```
sudo dnf install podman-compose
```
## Basic Usage
We have included fully functional sample stacks inside `examples/` directory.

3
SECURITY.md Normal file
View File

@ -0,0 +1,3 @@
## Security and Disclosure Information Policy for the Podman Compose Project
The Podman Compose Project follows the [Security and Disclosure Information Policy](https://github.com/containers/common/blob/master/SECURITY.md) for the Containers Projects.

File diff suppressed because it is too large Load Diff

7
requirements.txt Normal file
View File

@ -0,0 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pyyaml
python-dotenv

View File

@ -1,2 +1,5 @@
[bdist_wheel]
universal = 1
[metadata]
version = attr: podman_compose.__version__

View File

@ -1,23 +1,18 @@
import os
from setuptools import setup, find_packages
from setuptools import setup
try:
readme = open(os.path.join(os.path.dirname(__file__), 'README.md')).read()
except:
readme = ''
from podman_compose import __version__ as podman_compose_version
setup(
name='podman-compose',
version=podman_compose_version,
description="A script to run docker-compose.yml using podman",
long_description=readme,
long_description_content_type='text/markdown',
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
@ -41,7 +36,8 @@ setup(
include_package_data=True,
license='GPL-2.0-only',
install_requires=[
'pyyaml'
'pyyaml',
'python-dotenv',
],
# test_suite='tests',
# tests_require=[

8
test-requirements.txt Normal file
View File

@ -0,0 +1,8 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
coverage
pytest-cov
pytest
tox

View File

@ -1,7 +1,9 @@
FROM busybox
ARG buildno=1
ARG httpd_port=80
ARG other_variable=not_set
ENV httpd_port ${httpd_port}
ENV other_variable ${other_variable}
RUN mkdir -p /var/www/html/ && \
echo "ALT buildno=$buildno port=$httpd_port `date -Iseconds`" > /var/www/html/index.txt
CMD httpd -f -p "$httpd_port" -h /var/www/html

View File

@ -17,3 +17,9 @@ services:
image: my-busybox-httpd2
ports:
- 8000:8000
test_build_arg_argument:
build:
context: ./context
dockerfile: Dockerfile-alt
image: my-busybox-httpd2
command: env

4
tests/deps/README.md Normal file
View File

@ -0,0 +1,4 @@
```
podman-compose run --rm sleep /bin/sh -c 'wget -O - http://localhost:8000/hosts'
```

View File

@ -0,0 +1,24 @@
version: "3.7"
services:
web:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs:
- /run
- /tmp
sleep:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 3600"]
depends_on: "web"
tmpfs:
- /run
- /tmp
sleep2:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 3600"]
depends_on:
- sleep
tmpfs:
- /run
- /tmp

View File

@ -0,0 +1,5 @@
running the following command should give myval2
```
podman_compose run -l monkey -e ZZVAR1=myval2 env-test
```

View File

@ -0,0 +1,9 @@
version: '3'
services:
env-test:
image: busybox
command: sh -c "export | grep ZZ"
environment:
- ZZVAR1=myval1

15
tests/exit-from/README.md Normal file
View File

@ -0,0 +1,15 @@
We have service named sh1 that exits with code 1 and sh2 that exists with code 2
```
podman-compose up --exit-code-from=sh1
echo $?
```
the above should give 1.
```
podman-compose up --exit-code-from=sh2
echo $?
```
the above should give 2.

View File

@ -0,0 +1,21 @@
version: "3"
services:
too_long:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 3600; exit 0"]
tmpfs:
- /run
- /tmp
sh1:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 5; exit 1"]
tmpfs:
- /run
- /tmp
sh2:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 5; exit 2"]
tmpfs:
- /run
- /tmp

View File

@ -0,0 +1,29 @@
version: "3"
services:
echo:
image: busybox
command: ["/bin/busybox", "echo", "Zero"]
ports:
- '1234:1234'
environment:
- FOO=original
- BAR=original
# volumes:
# - ./original:/foo
# - ./original:/bar
echo1:
extends:
service: echo
command: ["/bin/busybox", "echo", "One"]
ports:
- '12345:12345'
# volumes:
# - ./local:/bar
# - ./local:/baz
env1:
extends:
service: echo
command: ["/bin/busybox", "env"]
environment:
- BAR=local
- BAZ=local

View File

@ -0,0 +1,7 @@
webapp:
build: .
ports:
- "8000:8000"
volumes:
- "/data"

View File

@ -0,0 +1,14 @@
version: "3"
services:
web:
extends:
file: common-services.yml
service: webapp
environment:
- DEBUG=1
cpu_shares: 5
important_web:
extends: web
cpu_shares: 10

1
tests/interpolation/.env Normal file
View File

@ -0,0 +1 @@
DOT_ENV_VARIABLE=This value is from the .env file

View File

@ -0,0 +1,8 @@
version: "3.7"
services:
variables:
image: busybox
command: ["/bin/busybox", "sh", "-c", "export | grep EXAMPLE"]
environment:
EXAMPLE_COLON_QUESTION_ERROR: ${NOT_A_VARIABLE:?Missing variable}

View File

@ -0,0 +1,8 @@
version: "3.7"
services:
variables:
image: busybox
command: ["/bin/busybox", "sh", "-c", "export | grep EXAMPLE"]
environment:
EXAMPLE_QUESTION_ERROR: ${NOT_A_VARIABLE?Missing variable}

View File

@ -0,0 +1,14 @@
version: "3.7"
services:
variables:
image: busybox
command: ["/bin/busybox", "sh", "-c", "export | grep EXAMPLE"]
environment:
EXAMPLE_VARIABLE: "Host user: $USER"
EXAMPLE_BRACES: "Host user: ${USER}"
EXAMPLE_COLON_DASH_DEFAULT: ${NOT_A_VARIABLE:-My default}
EXAMPLE_DASH_DEFAULT: ${NOT_A_VARIABLE-My other default}
EXAMPLE_DOT_ENV: $DOT_ENV_VARIABLE
EXAMPLE_LITERAL: This is a $$literal
EXAMPLE_EMPTY: $NOT_A_VARIABLE

View File

@ -0,0 +1,19 @@
# Multiple compose files
to make sure we get results similar to
```
docker-compose -f d1/docker-compose.yml -f d2/docker-compose.yml up -d
docker exec -ti d1_web1_1 sh -c 'set'
docker exec -ti d1_web2_1 sh -c 'set'
curl http://${d1_web1_1}:8001/index.txt
curl http://${d1_web1_1}:8002/index.txt
```
we need to verify
- project base directory and project name is `d1`
- `var12='d1/12.env'` which means `enf_file` was appended not replaced (which means that we normalize to array before merge)
- `var2='d1/2.env'` which means that paths inside `d2/docker-compose.yml` directory are relative to `d1`

View File

@ -0,0 +1 @@
var1=d1/1.env

View File

@ -0,0 +1 @@
var12=d1/12.env

View File

@ -0,0 +1 @@
var2=d1/2.env

View File

@ -0,0 +1,13 @@
version: '3'
services:
web1:
image: busybox
command: busybox httpd -h /var/www/html/ -f -p 8001
volumes:
- ./1.env:/var/www/html/index.txt
env_file: ./1.env
labels:
l1: v1
environment:
- mykey1=myval1

View File

@ -0,0 +1 @@
var12=d2/12.env

View File

@ -0,0 +1 @@
var2=d2/2.env

View File

@ -0,0 +1,18 @@
version: '3'
services:
web1:
env_file: ./12.env
labels:
- l1=v2
- l2=v2
environment:
mykey1: myval2
mykey2: myval2
web2:
image: busybox
command: busybox httpd -h /var/www/html/ -f -p 8002
volumes:
- ./2.env:/var/www/html/index.txt
env_file: ./2.env

View File

@ -0,0 +1,7 @@
version: '3'
networks:
shared-network:
driver: bridge
ipam:
config:
- subnet: 172.19.0.0/24

View File

@ -0,0 +1,33 @@
version: "3"
services:
web1:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
working_dir: /var/www/html
ports:
- 8001:8001
volumes:
- ./test1.txt:/var/www/html/index.txt:ro
web2:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"]
working_dir: /var/www/html
ports:
- 8002:8002
- target: 8003
host_ip: 127.0.0.1
published: 8003
protocol: udp
- target: 8004
host_ip: 127.0.0.1
published: 8004
protocol: tcp
- target: 8005
published: 8005
- target: 8006
protocol: udp
- target: 8007
host_ip: 127.0.0.1
volumes:
- ./test2.txt:/var/www/html/index.txt:ro

1
tests/ports/test1.txt Normal file
View File

@ -0,0 +1 @@
test1

1
tests/ports/test2.txt Normal file
View File

@ -0,0 +1 @@
test2

View File

@ -0,0 +1,12 @@
version: "3"
services:
web1:
image: busybox
command: httpd -f -p 80 -h /var/www/html
volumes:
- ./docker-compose.yml:/var/www/html/index.html
ports:
- "8080:80"
security_opt:
- seccomp:unconfined

View File

@ -0,0 +1,18 @@
version: "3.8"
services:
test:
image: busybox
command:
- cat
- /run/secrets/new_secret
tmpfs:
- /run
- /tmp
secrets:
- new_secret
secrets:
new_secret:
external: true
name: my_secret

View File

@ -0,0 +1,18 @@
version: "3.8"
services:
test:
image: busybox
command:
- cat
- /run/secrets/my_secret_2
tmpfs:
- /run
- /tmp
secrets:
- source: my_secret
target: new_secret
secrets:
my_secret:
external: true

View File

@ -0,0 +1,42 @@
version: "3.8"
services:
test:
image: busybox
command:
- /tmp/print_secrets.sh
tmpfs:
- /run
- /tmp
volumes:
- ./print_secrets.sh:/tmp/print_secrets.sh
secrets:
- my_secret
- my_secret_2
- source: my_secret_3
target: my_secret_3
uid: '103'
gid: '103'
mode: 400
- file_secret
- source: file_secret
target: custom_name
- source: file_secret
target: /etc/custom_location
- source: file_secret
target: unused_params_warning
uid: '103'
gid: '103'
mode: 400
secrets:
my_secret:
external: true
my_secret_2:
external: true
name: my_secret_2
my_secret_3:
external: true
name: my_secret_3
file_secret:
file: ./my_secret

1
tests/secrets/my_secret Normal file
View File

@ -0,0 +1 @@
important-secret-is-important

6
tests/secrets/print_secrets.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
ls -la /run/secrets/*
ls -la /etc/custom_location
cat /run/secrets/*
cat /etc/custom_location

3
tests/ulimit/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM busybox
COPY ./ulimit.sh /bin/ulimit.sh

View File

@ -0,0 +1,30 @@
version: "3"
services:
ulimit1:
image: ulimit_test
command: ["ulimit.sh" ]
ulimits: nofile=1001
build:
context: ./
dockerfile: Dockerfile
ulimit2:
image: ulimit_test
command: ["ulimit.sh" ]
ulimits:
- nproc=1002:2002
- nofile=1002
build:
context: ./
dockerfile: Dockerfile
ulimit3:
image: ulimit_test
command: [ "ulimit.sh" ]
ulimits:
nofile: 1003
nproc:
soft: 1003
hard: 2003
build:
context: ./
dockerfile: Dockerfile

10
tests/ulimit/ulimit.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
echo "soft process limit"
ulimit -S -u
echo "hard process limit"
ulimit -H -u
echo "soft nofile limit"
ulimit -S -n
echo "hard nofile limit"
ulimit -H -n

8
tests/vol/README.md Normal file
View File

@ -0,0 +1,8 @@
# to test create the two external volumes
```
podman volume create my-app-data
podman volume create actual-name-of-volume
podman-compose up
```

View File

@ -27,6 +27,9 @@ services:
working_dir: /var/www/html
volumes:
- myvol2:/var/www/html
- data:/var/www/html_data
- data2:/var/www/html_data2
- data3:/var/www/html_data3
volumes:
myvol2:
@ -38,3 +41,6 @@ volumes:
data2:
external:
name: actual-name-of-volume
data3:
name: my-app-data3

View File

@ -0,0 +1,34 @@
version: '3.6'
x-deploy-base: &deploy-base
restart_policy:
delay: 2s
x-common: &common
network: host
deploy:
<<: *deploy-base
networks:
hostnet: {}
networks:
hostnet:
external: true
name: host
volumes:
node-red_data:
services:
node-red:
<<: *common
image: busybox
command: busybox httpd -h /data -f -p 8080
deploy:
<<: *deploy-base
resources:
limits:
cpus: '0.5'
memory: 32M
volumes:
- node-red_data:/data