Skip to content

Commit

Permalink
Add podman support
Browse files Browse the repository at this point in the history
Add podman support
  • Loading branch information
paramah committed Sep 18, 2023
2 parents 5623d62 + afb8043 commit aec4a4d
Show file tree
Hide file tree
Showing 45 changed files with 384 additions and 227 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
name: goreleaser
command: curl -sL https://git.io/goreleaser | bash
- run:
name: Trigger docker `paramah/dind` build
name: Trigger container `paramah/dind` build
command: |
curl -X POST "https://drone.cynarski.pl/api/repos/Docker/dind/builds" -H "Authorization: Bearer ${DRONE_TOKEN}"
14 changes: 14 additions & 0 deletions .github/.mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pull_request_rules:
- name: Automatic merge on approval
conditions:
- "#approved-reviews-by>=1"
actions:
merge:
method: squash
- name: comment with default
conditions:
- label=comment
actions:
comment:
message: I 💙 Mergify
bot_account: Autobot
1 change: 1 addition & 0 deletions .ledo.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
runtime: docker
docker:
registry: registry.cynarski.pl
namespace: LeDo
Expand Down
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
![logo](./docs/logo.svg)

# Table of contents

Expand All @@ -10,17 +11,21 @@
- [Docker compose basics](#docker-compose)
- [Thanks](#thanks)


# About

Ledo (LeadDocker) is a simple tool to facilitate the daily work with docker-compose in a project (it doesn't work in swarm for now). It allows you to create run modes and fully automate them.

Ledo supports `docker` and `podman`, in the case of `podman` you need to configure it properly on your own system (links to tutorials can be found below)

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/paramah/ledo)

[![Chat on Matrix](https://matrix.to/img/matrix-badge.svg)](https://matrix.to/#/#ledo:matrix.cynarski.dev)

# Install

## Using binnary

Go to [Release page](https://github.com/paramah/ledo/releases), download, unpack and move to some `PATH` directory.
Go to [Release page](https://github.com/paramah/ledo/releases), download, unpack and move to some `PATH` directory.

You can also use the installation script:

Expand All @@ -36,11 +41,27 @@ go install github.com/paramah/[email protected]

# Usage

## Project code structure

```
├── app (**application**)
├── docker (**docker/podman stack**)
│   ├── docker-compose.dev.yml
│   ├── docker-compose.launch.yml
│   ├── docker-compose.test.yml
│   ├── docker-compose.yml
│   ├── docker-entrypoint.sh
│   ├── etc (**files to be copied into the container**)
│   └── test-entrypoint.sh
├── Dockerfile
```

## Init

Using the `ledo init` command, you can create a `.ledo.yml` configuration file that will contain all the necessary data to use ledo, example configuration file:

```yaml
runtime: docker
docker:
registry: registry.example.com
namespace: Test
Expand All @@ -61,6 +82,15 @@ Ledo executes the `docker-compose` command with properly prepared parameters, de

[![asciicast](https://asciinema.org/a/fPVl1wmtZpZXnPl3ZazoenUhD.png)](https://asciinema.org/a/fPVl1wmtZpZXnPl3ZazoenUhD)

## Podman compose

For `podman` Ledo executes `podman-compose` command.

## Podman configuration

- [Podman tutorial](https://github.com/containers/podman/blob/main/docs/tutorials/podman_tutorial.md)
- [Rootless tutorial](https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md)

# Thanks

- [Jazzy Innovations](https://jazzy.pro)
Expand Down
48 changes: 48 additions & 0 deletions app/cmd/container.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package cmd

import (
"github.com/paramah/ledo/app/cmd/container"
"github.com/paramah/ledo/app/modules/compose"
"github.com/paramah/ledo/app/modules/config"
"github.com/paramah/ledo/app/modules/context"
"github.com/urfave/cli/v2"
)

var CmdContainer = cli.Command{
Name: "container",
Aliases: []string{"c", "docker", "d"},
Category: catHelpers,
Usage: "container helper",
Description: `Manage compose tools (docker or podman) in project`,
Subcommands: []*cli.Command{
&container.CmdDockerPs,
&container.CmdDockerUp,
&container.CmdComposeBuild,
&container.CmdComposeDebug,
&container.CmdComposeDown,
&container.CmdComposeLogs,
&container.CmdComposeRestart,
&container.CmdComposeRun,
&container.CmdComposeExec,
&container.CmdDockerRm,
&container.CmdComposeShell,
&container.CmdComposeStart,
&container.CmdComposeUpOnce,
&container.CmdComposePull,
&container.CmdComposeStop,
&container.CmdDockerLogin,
&container.CmdPrune,
},
Before: func(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
if ctx.Config.Runtime == config.Docker {
compose.CheckDockerComposeVersion()
}

if ctx.Config.Runtime == config.Podman {
compose.CheckPodmanComposeVersion()
}

return nil
},
}
6 changes: 3 additions & 3 deletions app/cmd/docker/build.go → app/cmd/container/build.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand All @@ -9,8 +9,8 @@ import (
var CmdComposeBuild = cli.Command{
Name: "build",
Aliases: []string{"b"},
Usage: "build docker image",
Description: `Build all docker images`,
Usage: "build container image",
Description: `Build all container images`,
Action: RunComposeBuild,
Flags: []cli.Flag{
&cli.BoolFlag{
Expand Down
20 changes: 20 additions & 0 deletions app/cmd/container/configuration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package container

import (
"github.com/paramah/ledo/app/modules/compose"
"github.com/paramah/ledo/app/modules/context"
"github.com/urfave/cli/v2"
)

var CmdConfiguration = cli.Command{
Name: "configuration",
Usage: "how to configure container service",
Description: `Display configuration hints for containers`,
Action: RunConfiguration,
}

func RunConfiguration(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerBuild(ctx, *cmd)
return nil
}
2 changes: 1 addition & 1 deletion app/cmd/docker/debug.go → app/cmd/container/debug.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/down.go → app/cmd/container/down.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/exec.go → app/cmd/container/exec.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
10 changes: 5 additions & 5 deletions app/cmd/docker/login.go → app/cmd/container/login.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/container"
"github.com/paramah/ledo/app/modules/context"
"github.com/paramah/ledo/app/modules/docker"
"github.com/urfave/cli/v2"
)

var CmdDockerLogin = cli.Command{
Name: "login",
Aliases: []string{"l"},
Usage: "Docker Registry login",
Description: `Login to docker registry`,
Description: `Login to container registry`,
Subcommands: []*cli.Command{
&CmdDockerEcrLogin,
},
Expand Down Expand Up @@ -43,12 +43,12 @@ var CmdDockerEcrLogin = cli.Command{
},
},
Usage: "AWS Elastic Docker Registry",
Description: `Login to docker registry`,
Description: `Login to AWS Elastic Container Registry`,
Action: RunDockerEcrLogin,
}

func RunDockerEcrLogin(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
docker.DockerEcrLogin(ctx)
container.DockerEcrLogin(ctx)
return nil
}
4 changes: 2 additions & 2 deletions app/cmd/docker/logs.go → app/cmd/container/logs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand All @@ -10,7 +10,7 @@ var CmdComposeLogs = cli.Command{
Name: "logs",
Aliases: []string{"l"},
Usage: "logs from containers",
Description: `Get fqn docker image defined as main service in config file`,
Description: `Get fqn container image defined as main service in config file`,
Action: RunComposeLogs,
}

Expand Down
19 changes: 10 additions & 9 deletions app/cmd/docker/prune.go → app/cmd/container/prune.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package docker
package container

import (
"os"

"github.com/AlecAivazis/survey/v2"
"github.com/paramah/ledo/app/logger"
"github.com/paramah/ledo/app/modules/container"
"github.com/paramah/ledo/app/modules/context"
"github.com/paramah/ledo/app/modules/docker"
"github.com/urfave/cli/v2"
"os"
)

var CmdPrune = cli.Command{
Name: "prune",
Usage: "clean and prune docker ",
Description: `Old and working docker system prune version.`,
Usage: "clean and prune container ",
Description: `Old and working container system prune version.`,
Action: RunPrune,
}

Expand All @@ -21,20 +22,20 @@ func RunPrune(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)

if ctx.Mode.CurrentMode != "dev" {
logger.Exit("docker prune is only available in dev mode!")
logger.Exit("container prune is only available in dev mode!")
os.Exit(255)
}

wantPrune := false
prompt := &survey.Confirm{
Message: "Do You want prune docker (all data will be irretrievably lost) ?",
}
Message: "Do You want prune containers (all data will be irretrievably lost) ?",
}
err = survey.AskOne(prompt, &wantPrune)
if err != nil {
return err
}
if wantPrune {
err = docker.ExecDockerPrune(ctx)
err = container.ExecPrune(ctx)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/ps.go → app/cmd/container/ps.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
6 changes: 3 additions & 3 deletions app/cmd/docker/pull.go → app/cmd/container/pull.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand All @@ -8,8 +8,8 @@ import (

var CmdComposePull = cli.Command{
Name: "pull",
Usage: "docker image pull",
Description: `Pull docker image from registry server`,
Usage: "container image pull",
Description: `Pull container image from registry server`,
Action: RunComposePull,
}

Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/restart.go → app/cmd/container/restart.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/rm.go → app/cmd/container/rm.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/run.go → app/cmd/container/run.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/shell.go → app/cmd/container/shell.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/start.go → app/cmd/container/start.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/stop.go → app/cmd/container/stop.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/docker/up.go → app/cmd/container/up.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand Down
4 changes: 2 additions & 2 deletions app/cmd/docker/uponce.go → app/cmd/container/uponce.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package docker
package container

import (
"github.com/paramah/ledo/app/modules/compose"
Expand All @@ -9,7 +9,7 @@ import (
var CmdComposeUpOnce = cli.Command{
Name: "uponce",
Usage: "up one container",
Description: `Up one container from docker compose stack`,
Description: `Up one container from container compose stack`,
Action: RunComposeUpOnce,
}

Expand Down
Loading

0 comments on commit aec4a4d

Please sign in to comment.