diff --git a/.gitignore b/.gitignore index ad4b890..2a433e9 100644 --- a/.gitignore +++ b/.gitignore @@ -159,8 +159,8 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - +.idea/ +.vscode/ *.json *.toml diff --git a/README.md b/README.md index 6a96986..964c376 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ docker network create --driver bridge masterbase-network Build the DB: ```sh -docker build -f Dockerfile.db . -t db +docker build -f database.Dockerfile . -t db ``` Run the DB: @@ -160,7 +160,7 @@ pdm run alembic upgrade head Build the API: ```sh -docker build -f Dockerfile.api . -t api +docker build -f api.Dockerfile . -t api ``` Now before we run, we need to inject the IPv4 of the db container. We can find this by running `docker network inspect masterbase-network` and inspecting the output. In my case, I see the IP as `172.20.0.2` diff --git a/Dockerfile.api b/api.Dockerfile similarity index 100% rename from Dockerfile.api rename to api.Dockerfile diff --git a/build.env b/build.env new file mode 100644 index 0000000..8abfa2d --- /dev/null +++ b/build.env @@ -0,0 +1,6 @@ +POSTGRES_USER=MEGASCATTERBOMB +POSTGRES_PASSWORD=masterbase +POSTGRES_HOST=172.20.1.10 +POSTGRES_PORT=5432 +API_HOST=172.20.1.20 +DEVELOPMENT=true \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..7eb0582 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,42 @@ +name: masterbase + +services: + api: + container_name: masterbase-api + env_file: + - ./build.env + build: + dockerfile: api.Dockerfile + args: + DEVELOPMENT=${DEVELOPMENT} + links: + - db + restart: unless-stopped + ports: + - 8000:8000 + networks: + masterbase-network: + ipv4_address: ${API_HOST} + + db: + container_name: masterbase-db + env_file: + - ./build.env + build: + dockerfile: database.Dockerfile + restart: unless-stopped + ports: + - 8050:${POSTGRES_PORT} + networks: + masterbase-network: + ipv4_address: ${POSTGRES_HOST} + +networks: + masterbase-network: + name: masterbase-network-dev + driver: bridge + ipam: + driver: default + config: + - subnet: 172.20.0.0/16 + gateway: 172.20.0.1 \ No newline at end of file diff --git a/Dockerfile.db b/database.Dockerfile similarity index 100% rename from Dockerfile.db rename to database.Dockerfile