GithubHelp home page GithubHelp logo

hello_docker's Introduction

Python application

hello_docker

Almost a whole CI/CD pipeline repo that show to build a docker image, publish it and deploy it. I will keep updating this repo until it reaches the complete CI/CD pipeline.

Create a virtual environment

pyhton -m venv .env

Activate the virtual environment

source .env/bin/activate

Clone this repo

git clone https://github.com/ceste/hello_docker.git

Install the requirements

pip install -r requirements

Run the script

python main.py --name nadia
python main.py --name sarah

Create a volume to persist the output (optional)

docker volume create <volume_name>
docker volume create tmp

Inspect the volume to get directory location (optional)

docker volume inspect <volume_name>
docker volume inspect tmp

Build docker image

docker build -t docker-greeting .

Run docker image

docker run docker-greeting python main.py --name cst

or

run if you want to see the output files creation

docker run --mount source=<volumne_name>,target=<WORKDIR> <image_name> <command_to_run_your_script>
docker run --mount source=tmp,target=/app docker-greeting python main.py --name cst

Tag docker image

To do this, you need to have a repo in docker hub. Essentially this will map you local image to docker hub repo.

Syntax:

docker tag local-image:tagname new-repo:tagname
docker tag docker-greeting:latest chandrasutrisnotjhong/docker-greeting:latest

Push image to docker hub

Make sure you login using your docker account

Syntax:

docker push new-repo:tagname
docker push chandrasutrisnotjhong/docker-greeting:latest

Run image from the repo (should run it from your production environment)

If the image is not available on local, it will download the image first and then run it.

docker run -it chandrasutrisnotjhong/docker-greeting python main.py --name abc

If there is new build, pull the latest build and then run above command:

docker pull chandrasutrisnotjhong/docker-greeting:latest

Push local docker image to Heroku

Additional steps if what you built is an API

Login to Heroku

heroku login

Login to Heroku Container Registry

heroku container:login

Create an app on Heroku

heroku create <name-for-your-app>
heroku create cst-hello-docker

Push the container into Heroku

heroku container:push web --app <name-for-your-app>
heroku container:push web --app cst-hello-docker

Deploy the container

heroku container:release web <name-for-your-app>
heroku container:release web --app cst-hello-docker

Open your app

https://<name-for-your-app>.herokuapp.com/
https://cst-hello-docker.herokuapp.com/

Deploy Docker Image to Heroku App is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

References:

hello_docker's People

Contributors

ceste avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.