muhammedikinci / pin

WIP - Pin - local pipeline project with Docker Golang API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool



pin πŸ”₯ pipeline

WIP - Local pipeline project with Docker Golang API.

pingif

terminal from terminalgif.com

🌐 Installation

Download latest release

You can download latest release from here

Install with cloning

Clone the pin

git clone https://github.com/muhammedikinci/pin

Download packages

go mod download

Build executable

go build -o pin ./cmd/cli/.

Or you can run directly

go run ./cmd/cli/. apply -n "test" -f ./testdata/test.yaml

βš™οΈ Configuration

Sample yaml file

workflow:
  - run

logsWithTime: true

run:
  image: golang:alpine3.15
  copyFiles: true
  soloExecution: true
  script:
    - go mod download
    - go run .
    - ls
  port:
    - 8082:8080

You can create separate jobs like the run stage and if you want to run these jobs in the pipeline you must add its name to workflow.

copyFiles

default: false

If you want to copy all projects filed to the docker container, you must set this configuration to true

soloExecution

default: false

When you add multiple commands to the script field, commands are running in the container as a shell script. If soloExecution is set to true each command works in a different shell script.

soloExecution => false

# shell#1
cd cmd
ls

soloExecution => true

# shell#1
cd cmd
# shell#2
ls

If you want to see all files in the cmd folder you must set soloExecution to false or you can use this:

# shell#1
cd cmd && ls

logsWithTime

default: false

logsWithTime => true

βš‰ 2022/05/08 11:36:30 Image is available
βš‰ 2022/05/08 11:36:30 Start creating container
βš‰ 2022/05/08 11:36:33 Starting the container
βš‰ 2022/05/08 11:36:35 Execute command: ls -a

logsWithTime => false

βš‰ Image is available
βš‰ Start creating container
βš‰ Starting the container
βš‰ Execute command: ls -a

port

default: empty mapping

You can use this feature for port forwarding from container to your machine with multiple mapping

  port:
    - 8082:8080
    - 8083:8080

copyIgnore

default: empty mapping

You can use this feature to ignore copying the specific files in your project to the container.

Sample configuration yaml

run:
  image: node:current-alpine3.15
  copyFiles: true
  soloExecution: true
  port:
    - 8080:8080
  copyIgnore:
    - server.js
    - props
    - README.md
    - helper/.*/.py

Actual folder structure in project

index.js
server.js
README.md
helper:
    - test.py
    - mock
        test2.py
    - api:
        index.js
    - props:
        index.js

Folder structure in container

index.js
helper:
    - mock (empty)
    - api:
        index.js

parallel

default: false

If you want to run parallel job, you must add parallel field and the stage must be in workflow(position doesn't matter)

workflow:
  - testStage
  - parallelJob
  - run

...

parallelJob:
  image: node:current-alpine3.15
  copyFiles: true
  soloExecution: true
  parallel: true
  script:
    - ls -a

Tests

go test ./...

Checklist

  • Implement web interface
  • Support concurrent jobs βœ…Issue#9
  • Add working with remote docker deamon support
  • Change image pulling logs (get only status logs)βœ…Issue#1
  • Add custom ignore configuration to copyFiles for project files (like gitignore) βœ…Issue#7
  • Add shared artifacts support between different jobs
  • Add timestamp to container names βœ…Issue#2
  • Create small pieces with extracting codes from runner struct and write unit test:
    • Image Manager βœ…Issue#3
    • Container Manager βœ…Issue#4
    • Shell Commander βœ…Issue#5
    • Parser
    • Runner
  • Add port expose support βœ…Issue#6
  • Support long living containers
  • Add concurrency between jobs and graceful shutdown with global context βœ…Issue#8

Contact

Muhammed Δ°kinci - muhammedikinci@outlook.com