Skip to content

Generate systemd unit files from docker compose service definitions

License

Notifications You must be signed in to change notification settings

xtracdev/compose2systemd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

compose2systemd

This project parses a docker compose file and generates a systemd unit file to control a docker compose service as a systemd service.

go run main.go unit.go -compose-file-path ../es-atom-pub/cmd/proxy/docker-compose.yml -app-name myapp

[Unit]
Description=Service unit for docker service atomfeedpub
After=docker.service
BindsTo=docker.service
Conflicts=shutdown.target reboot.target halt.target

[Service]
Environment=APP='atomfeedpub'
TimeoutStartSec=0
TimeoutStopSec=30
Restart=always
RestartSec=10

WorkingDirectory=/opt/dockerapps/myapp

ExecStartPre=-/usr/local/bin/docker-compose kill $APP
ExecStartPre=-/usr/local/bin/docker-compose rm $APP
ExecStartPre=-/usr/local/bin/docker-compose rm -f $APP
ExecStart=/usr/bin/envconsul -consul={{consul_addr}} -once -prefix=dc/{{env_prefix}} env /usr/local/bin/docker-compose up --force-recreate --no-deps $APP

ExecStop=/usr/local/bin/docker-compose stop $APP

NotifyAccess=all

[Install]
WantedBy=multi-user.target

Dependencies

go get github.com/docker/libcompose

Contributing

To contribute, you must certify you agree with the Developer Certificate of Origin by signing your commits via git -s. To create a signature, configure your user name and email address in git. Sign with your real name, do not use pseudonyms or submit anonymous commits.

In terms of workflow:

  1. For significant changes or improvement, create an issue before commencing work.
  2. Fork the respository, and create a branch for your edits.
  3. Add tests that cover your changes, unit tests for smaller changes, acceptance test for more significant functionality.
  4. Run gofmt on each file you change before committing your changes.
  5. Run golint on each file you change before committing your changes.
  6. Make sure all the tests pass before committing your changes.
  7. Commit your changes and issue a pull request.

License

(c) 2016 Fidelity Investments Licensed under the Apache License, Version 2.0

About

Generate systemd unit files from docker compose service definitions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages