Utilizzo la finestra mobile-compose per distribuire un'applicazione web Python multicontainer. Ho difficoltà a capire come creare tabelle nel database postgresql durante la compilazione, quindi non devo aggiungerle manualmente con psql.Utilizzo di docker-compose per creare tabelle nel database postgresql
Il mio file finestra mobile-compose.yml è:
web:
restart: always
build: ./web
expose:
- "8000"
links:
- postgres:postgres
volumes:
- /usr/src/flask-app/static
env_file: .env
command: /usr/local/bin/gunicorn -w 2 -b :8000 app:app
nginx:
restart: always
build: ./nginx/
ports:
- "80:80"
volumes:
- /www/static
volumes_from:
- web
links:
- web:web
data:
restart: always
image: postgres:latest
volumes:
- /var/lib/postgresql
command: "true"
postgres:
restart: always
image: postgres:latest
volumes_from:
- data
ports:
- "5432:5432"
io non voglio avere per entrare psql per inserire:
CREATE DATABASE my_database;
CREATE USER this_user WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE "my_database" to this_user;
\i create_tables.sql
Gradirei una guida su come creare il tabelle.
questo non funziona con l'ultima versione dell'immagine postgres :( – dopatraman