chore: add examples

This commit is contained in:
Xyphuz 2022-05-25 17:16:38 +08:00
parent e8ed141c09
commit a71f82572c
8 changed files with 76 additions and 12 deletions

View file

@ -29,6 +29,7 @@ jobs:
docker compose -f tests/ymls/networks/docker-compose.yml config -q docker compose -f tests/ymls/networks/docker-compose.yml config -q
docker compose -f tests/ymls/ports/docker-compose.yml config -q docker compose -f tests/ymls/ports/docker-compose.yml config -q
docker compose -f tests/ymls/volumes/docker-compose.yml config -q docker compose -f tests/ymls/volumes/docker-compose.yml config -q
docker compose -f examples/full-stack-node-app/docker-compose.yml config -q
- name: Setup Python 3.10.4 - name: Setup Python 3.10.4
uses: actions/setup-python@v3 uses: actions/setup-python@v3

2
.gitignore vendored
View file

@ -159,3 +159,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear # 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. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
*.png

View file

@ -0,0 +1,59 @@
version: "3.9"
services:
node:
build:
context: .
dockerfile: Dockerfile.node
api:
image: "awesome/api"
extends:
service: node
build:
args:
PACKAGE_PATH: api
WORKING_DIR: /usr/src/
expose:
- 8000
ports:
- 8000:8000
environment:
- NODE_ENV=development
volumes:
- ./api:/usr/src
depends_on:
- postgres
- adminer
command: ["npm", "start"]
frontend:
extends:
service: node
build:
args:
PACKAGE_PATH: frontend
WORKING_DIR: /usr/src/
expose:
- 3000
ports:
- 3000:3000
environment:
- REACT_APP_ENV=development
- BACKEND=api:8000
- HTTPS=true
- NODE_PATH=/usr/src/
volumes:
- ./frontend:/usr/src
depends_on:
- api
command: ["npm", "start"]
postgres:
image: postgres
restart: always
adminer:
image: adminer
ports:
- 8080:8080

View file

@ -11,17 +11,19 @@ runner = CliRunner()
@pytest.mark.parametrize( @pytest.mark.parametrize(
"test_file_path", "test_file_path",
[ [
"builds/docker-compose", "tests/ymls/builds/docker-compose.yml",
"depends_on/docker-compose", "tests/ymls/depends_on/docker-compose.yml",
"extends/docker-compose", "tests/ymls/extends/docker-compose.yml",
"links/docker-compose", "tests/ymls/links/docker-compose.yml",
"networks/docker-compose", "tests/ymls/networks/docker-compose.yml",
"ports/docker-compose", "tests/ymls/others/docker-compose.yml",
"volumes/docker-compose", "tests/ymls/ports/docker-compose.yml",
"tests/ymls/volumes/docker-compose.yml",
"examples/full-stack-node-app/docker-compose.yml",
], ],
) )
def test_cli(test_file_path: str) -> None: def test_cli(test_file_path: str) -> None:
input_path = f"tests/ymls/{test_file_path}.yml" input_path = f"{test_file_path}"
output_path = "compose-viz-test.png" output_path = "compose-viz-test.png"
result = runner.invoke(cli.app, ["-o", output_path, input_path]) result = runner.invoke(cli.app, ["-o", output_path, input_path])

View file

@ -9,4 +9,4 @@ services:
image: awesome/backend image: awesome/backend
build: build:
context: backend context: backend
dockerfile: ../backend.Dockerfile dockerfile: ../backend.Dockerfile

View file

@ -11,4 +11,4 @@ services:
derive_from_file: derive_from_file:
extends: extends:
file: web.yml file: web.yml
service: web service: web

View file

@ -2,4 +2,4 @@ version: "3.9"
services: services:
web: web:
image: awesome/web image: awesome/web

View file

@ -6,4 +6,4 @@ services:
links: links:
- "db:database" - "db:database"
db: db:
image: mysql image: mysql