Skip to content

Instantly share code, notes, and snippets.

@angeloreale
Last active February 9, 2019 17:24
Show Gist options
  • Save angeloreale/6bcbb932a88662cae7cb87eae14144f7 to your computer and use it in GitHub Desktop.
Save angeloreale/6bcbb932a88662cae7cb87eae14144f7 to your computer and use it in GitHub Desktop.
Dockerizing a Node.js and MongoDB app with CI/CD Pipelines on Gitlab for staging and production environments.
# /etc/systemd/system/yournodeservice.service
[Unit]
Description=Docker Compose Application Service
Requires=docker.service
After=docker.service
[Service]
Type=simple
RemainAfterExit=yes
WorkingDirectory=/path/to/prod/ #path to your dev/prod node service
ExecStart=/usr/local/bin/docker-compose up --no-deps --force-recreate -d dev/prod #starts your dev/prod node service
ExecStop=/usr/local/bin/docker-compose stop dev/prod #stops your dev/prod node service
TimeoutStartSec=0
Restart=always
StartLimitIntervalSec=60
StartLimitBurst=3
Requires=mongo.service #your mongo service
After=mongo.service #your mongo service
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment