2024-09-29.17-33-45.mp4
docker volume create "boston-data"
docker run --rm -d \
--name "boston-db" \
--env-file=.env \
-p 5432:5432 \
-v "boston-data:/var/lib/postgresql/data/" \
postgres:latest
source .env
docker exec -i boston-db psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f /dev/stdin < db.sql
FROM python:3.9-slim
WORKDIR /app/
COPY ./app.py ./requirements.txt ./.env /app/
EXPOSE 8080/tcp
RUN pip install -r requirements.txt
CMD [ "python", "app.py"]
docker build -t otreblan/app:v1.0 .
docker run --rm -d \
-p 8080:8080 \
-e DB_HOST="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' boston-db)" \
--name "boston-app" \
otreblan/app:v1.0
url: https://hub.docker.com/repository/docker/otreblan/app/general
services:
boston-db:
container_name: boston-db
env_file: .env
image: "postgres:latest"
ports:
- "5432:5432"
volumes:
- boston-data:/var/lib/postgresql/data/
boston-app:
container_name: boston-app
environment:
DB_HOST: 172.17.0.2
ports:
- "8080:8080"
image: "otreblan/app:v1.0"
volumes:
boston-data:
name: boston-data
driver: local
docker compose up -d