Customizable Professional Developer Portfolio for Beginners with Docker Stack
This repository was created as a resource for my YouTube tutorial.
- Run your app and view it in your browser @
localhost
orlocalhost:80
:
cd dev_portfolio_simplified
docker compose up
- update
init_db.py
with your personal information and projects. - update
static/style.css
with your favourite styling. - update
static/script.js
with your JavaScript browser intercations. - saving each of the above files, and refreshing the web page - will automatically update your website locally.
- switch to a production server like Green Unicorn, by updating your Dockerfile:
FROM python:3.12-slim
WORKDIR /app
RUN pip install flask
RUN pip install gunicorn
COPY . .
CMD ["gunicorn", "--workers=5", "--bind", "0.0.0.0:5000", "main:app"]
- pre-build a Docker image, to later specify it in your docker-compose file:
docker build -t my-portfolio .
- update docker-compose file with the pre-build image:
services:
web:
image: my-portfolio:latest
ports:
- "80:5000"
volumes:
- ./:/app
deploy:
restart_policy:
condition: any
updater:
image: my-portfolio:latest
command: ["tail", "-f", "/dev/null"]
volumes:
- ./:/app
deploy:
restart_policy:
condition: any
- activate swarm more and deploy the GUI and database services in a stack:
docker build -t my-portfolio .
docker swarm init
docker stack deploy -c docker-compose.yml my-portfolio
- update
init_db.py
and save it. - find container id of the database updater service with:
docker ps
- update database service without collapsing the application
docker exec [CONTAINER ID GOES HERE] python3 /app/init_db.py
For 10% off on your VPS plan please navigate to:
http://hostinger.com/pythonsimplified
And enter the coupon code: PYTHONSIMPLIFIED
If you're not sure what Flask is, or why do we need Docker, or how on earth do we work with SQLite, please checkout the following learning resources on YouTube to get you up to speed:
⭐ Simple Hello World Web App with Flask:
https://youtu.be/6plVs_ytIH8
⭐ Introduction to SQLite:
https://youtu.be/Ohj-CqALrwk
⭐ Advanced Web App with Flask, and SQLite:
https://youtu.be/v3CSQkPJtAc
⭐ Introduction to Docker:
https://youtu.be/-l7YocEQtA0