-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
118 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Deploy | ||
{id: deploy} | ||
|
||
## Digital Ocean | ||
{id: digital-ocean} | ||
|
||
* [Digital Ocean](https://www.digitalocean.com/?refcode=0d4cc75b3a74) | ||
|
||
## Stand-alone Application to deploy | ||
{id: stand-alone-application-to-deploy} | ||
|
||
* A stand-alone Docker image that exposes a single port | ||
|
||
 | ||
 | ||
 | ||
 | ||
|
||
Locally | ||
|
||
``` | ||
docker build -t flasker . | ||
docker run --rm -p5000:5000 flasker | ||
http://localhost:5000/api/add?a=3&b=4 | ||
``` | ||
|
||
## Deployment on Digital Ocean | ||
{id: deployment-on-digital-ocean} | ||
|
||
|
||
* [Digital Ocean](https://cloud.digitalocean.com/) | ||
* Go to **Marketplace**, search for Docker | ||
* Click on **Create Docker Droplet** | ||
* Basic $5/month | ||
* New York is fine | ||
* Select SSH key | ||
|
||
``` | ||
ssh root@remotehost | ||
DOCKER_HOST=ssh://user@remotehost docker build -t flasker . | ||
DOCKER_HOST=ssh://user@remotehost docker run -d --name flask --restart unless-stopped -p5000:5000 flasker | ||
``` | ||
|
||
* We use the `-d` flag to convert it into a daemon | ||
* We use `--restart unless-stopped` to tell Docker to restert on reboot | ||
|
||
* List containers | ||
|
||
``` | ||
DOCKER_HOST="ssh://user@remotehost" docker ps | ||
``` | ||
|
||
Upgrade: | ||
|
||
``` | ||
DOCKER_HOST=ssh://user@remotehost docker build -t flasker . | ||
DOCKER_HOST=ssh://user@remotehost docker container stop flask | ||
DOCKER_HOST=ssh://user@remotehost docker container rm flask | ||
DOCKER_HOST=ssh://user@remotehost docker run -d --name flask --restart unless-stopped -p5000:5000 flasker | ||
``` | ||
|
||
* [restart policy](https://docs.docker.com/config/containers/start-containers-automatically/) | ||
|
||
|
||
TODO: persistent data | ||
|
||
## Multi-container Application to deploy | ||
{id: multi-container-application} | ||
|
||
* A multi-container Docker app usin Docker Compose | ||
|
||
|
||
## Digital Ocean with Docker compose | ||
{id: digital-ocean-docker-compose} | ||
|
||
* [article](https://www.docker.com/blog/how-to-deploy-on-remote-docker-hosts-with-docker-compose/) | ||
* Create Droplet based on Docker | ||
* ssh to it, `apt-get update`, `apt-get dist-upgrade`, `reboot` | ||
* `DOCKER_HOST="ssh://user@remotehost" docker-compose up -d` | ||
|
||
Re-deploy | ||
|
||
* `DOCKER_HOST="ssh://user@remotehost" docker-compose build web` | ||
* `DOCKER_HOST="ssh://user@remotehost" docker-compose up -d web` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
"perl.md", | ||
"networking.md", | ||
"postgresql.md", | ||
"deploy.md", | ||
"appendix.md", | ||
"old.md" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters