· 7 years ago · Dec 06, 2018, 02:24 AM
1# base image
2FROM postgres:10.4-alpine
3
4# run the db file on init
5ADD yourappdb.sql /docker-entrypoint-initdb.d
6
7version: '3.6'
8services:
9 postgres:
10 build:
11 context: ./postgres
12 dockerfile: Dockerfile
13 ports:
14 - 5435:5432
15 volumes:
16 - './postgres/pgdata:/var/lib/postgresql/data'
17 # - './postgres/yourappdb.sql:/docker-entrypoint-initdb.d/yourappdb.sql'
18 # - './postgres/init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh'
19 environment:
20 - POSTGRES_USER=myname
21 - POSTGRESS_PASSWORD=test
22 - POSTGRES_DATABASE=yourappdb
23 api:
24 build:
25 dockerfile: Dockerfile.dev
26 context: ./server
27 volumes:
28 - './server:/usr/src/app'
29 ports:
30 - 5001:5000
31 environment:
32 - FLASK_APP=server/index.py
33 - FLASK_ENV=development
34 - APP_SETTINGS=config.DevelopmentConfig
35 - DATABASE_URL=postgres://myname:test@postgres:5432/yourappdb
36 - DATABASE_TEST_URL=postgres://postgres:postgres@postgres:5432/yourappdb
37 depends_on:
38 - postgres
39
40--
41-- PostgreSQL database dump
42--
43
44-- Dumped from database version 9.6.5
45-- Dumped by pg_dump version 9.6.5
46
47SET statement_timeout = 0;
48SET lock_timeout = 0;
49SET idle_in_transaction_session_timeout = 0;
50SET client_encoding = 'UTF8';
51SET standard_conforming_strings = on;
52SET check_function_bodies = false;
53SET client_min_messages = warning;
54SET row_security = off;
55
56--
57-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
58--
59
60CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
61
62
63--
64-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
65--
66
67COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
68
69
70SET search_path = public, pg_catalog;
71
72SET default_tablespace = '';
73
74SET default_with_oids = false;
75
76--
77-- Name: administrator; Type: TABLE; Schema: public; Owner: myname
78--
79
80CREATE TABLE administrator (
81 id integer NOT NULL,
82 "timestamp" timestamp without time zone,
83 email character varying(255)
84);
85
86
87ALTER TABLE administrator OWNER TO myname;
88
89CREATE USER myname WITH PASSWORD 'test';
90CREATE DATABASE yourappdb;
91GRANT ALL PRIVILEGES ON DATABASE yourappdb TO myname;
92/c yourappdb;