How to deploy to Digital Ocean?

I am a FrontEnd Angular2 guy not a dev-op. I am trying to automate Docker deployment to my DigitalOcean server. I cannot figure this out. Any help?

I have the code pushed to github, the dockerHub is working, I can manually deploy the images by pushing and pulling.

CircleCi is working with github - the build starts and the tests run. This is as far as it gets and then it times out.

This is only a test for now so I have a basic nodeJs express site and a simple true/false test. I just want to deploy this using CircleCi 2.0

Here is a plunk of the main files - Docker Plunk

Been at this for days now - 13 failed tests so far!

1 Like

I’m not sure what you’re doing exactly so I don’t know the best method to suggest. What I can say is, the same way you would deploy your application now, without CircleCI, is the way you would with CircleCI. Builds run in a Unix environment.

If your production environment is Git based, then git push to deploy. If it’s simply normal files on a filesystem, then use scp or rsync. If it’s Docker based, then log in to the remote machine with ssh, docker stop, docker pull, and docker run.

All depends on what you are doing.

I would do this, in your CircleCI config file.

Thanks for the advice.
Yes I am using git synced to circleci.
Circleci then runs build when git updated.

Update:
Tests use Karma to run. Just discovered that you need to set Karma.conf to singleRun otherwise the tests never end and then blocks the deployment.
So now the deployment completes - get Green build finally.

Deployment still not working though.

And what are you doing for deployment? What are the errors?

Config snippets and error snippets will help here.

Hi @FelicianoTech have gotten further now. Thanks for the help.
The latest issue now is that the deployment stops due to ssh key confirmation.

So to date so far:

I have my code on a local dev laptop.
The code is a simple Express app with Docker (also docker-compose).
This gets pushed to Github. This then connects to CircleCi (and DockerHub)
CircleCi runs and passes the tests then starts the deploy and gets stuck.
I am trying to deploy as simple test to my DigitalOcean server.

CircleCi spins up the environment, sets up the ssh,
checks out the code, installs docker-compose, sets up docker engine?
but stops at the deploy.

I think I am getting confused with all the ssh configuration. I am obviously doing something wrong. Anything anyone can do to help me get my head around this issue would be great?
I know this is probably a real simple config problem.

How I see it is that I need somehow to get an ssh key added. So far it has not worked?
It looks like the deploy is connecting to DigitalOcean server but the ssh is failing.


Deployment task: (terminal output)

#!/bin/bash -eo pipefail
if [ "${CIRCLE_BRANCH}" == "node-test-dev" ]; then
  ssh $DEPLOY_USER@$DEPLOY_HOST
  docker login -u $DOCKER_USER -p DOCKER_PASS 
  docker run -d cuznerdexter/cuzdex-hub:latest
fi

The authenticity of host 'xx.xxx.xx.xxx' can't be established.
ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? 

I have also copied the main files into this [plunkr] (https://plnkr.co/edit/yotHzy8HGYJPWX70JyBn?p=catalogue) to help.

I have the same problem. Adding the ssh key is enough on 1.0, but on 2.0 I have to manually SSH in and hit “yes” every time.

The 2.0 deploy guide only covers specific services like AWS/Heroku, there’s no general guide: https://circleci.com/docs/2.0/deployment-integrations/

I figured it out and posted here: SCP authenticity requires input, freezes build

For the OP case:

- checkout
- run: ssh-keyscan $DEPLOY_HOST >> ~/.ssh/known_hosts

It will only works it lives after -checkout as checkout seems to create the file.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.