I have been using NodeJs for a while for developing web applications. While it's not the perfect environment to develop, shipping applications is pretty easy as almost all hosting providers support it.
Recently I developed a Flask web app. It's very fun to program in Python. It's actually my favorite programming language. However, deploying Flask app turned out to be hard. I was trying to deploy on Microsoft Azure, which is quite popular cloud provider. The thing is languages like NodeJs, PHP etc. are well supported.
In order to solve my deployment issue, I turned to Docker. After reading bit of documentation, it actually turned out to be very easy process. I have to say I really enjoy building containers and pushing to remote servers. If it works on local, it works on remote servers 😄
Here is my
FROM python:3.6 MAINTAINER Nar Kumar Chhantyal RUN apt update && apt install python-dev -y COPY . /app WORKDIR /app RUN pip install -r requirements.txt EXPOSE 8000 ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:8000"] CMD ["app:app"]
With that, I can now build container:
docker build . -t container-name:latest
And then run it:
docker run -p 8000:8000 container-name:latest
I can run this in any machines which supports Docker. I can also share this Dockerfile with my coworkers and they will be able to setup this app with single command.
There is bit more to it, including uploading to remote registries like Docker Hub. I have pushed all the codebase on Github https://github.com/chhantyal/flask-docker.
Feel free to try it out and ship apps without getting stuck 🚀