chore: implement new image parsing rule

This commit is contained in:
Xyphuz 2022-05-25 17:47:23 +08:00
parent 469f1f6122
commit cbb1f0575d
4 changed files with 86 additions and 14 deletions

View file

@ -42,12 +42,19 @@ class Parser:
service_image: Optional[str] = None
if service.get("build"):
if type(service["build"]) is str:
service_image = "build from " + service["build"]
service_image = f"build from '{service['build']}'"
elif type(service["build"]) is dict:
assert service["build"].get("context"), "Missing build context, aborting."
service_image = "build from " + str(service["build"]["context"])
elif service.get("image"):
service_image = service["image"]
if service["build"].get("context") and service["build"].get("dockerfile"):
service_image = (
f"build from '{service['build']['context']}' using '{service['build']['dockerfile']}'"
)
elif service["build"].get("context"):
service_image = f"build from '{service['build']['context']}'"
if service.get("image"):
if service_image:
service_image += ", image: " + service["image"]
else:
service_image = service["image"]
service_networks: List[str] = []
if service.get("networks"):

View file

@ -23,8 +23,9 @@ services:
volumes:
- ./api:/usr/src
depends_on:
- postgres
- db
- adminer
- redis
command: ["npm", "start"]
frontend:
@ -38,22 +39,34 @@ services:
- 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
db:
image: "awesome/db"
extends:
service: postgres
from: postgres.yml
restart: always
volumes:
- "db-data:/data"
- type: bind
source: /var/run/postgres/postgres.sock
target: /var/run/postgres/postgres.sock
redis:
image: "awesome/redis"
restart: always
expose:
- 6379
adminer:
image: adminer
image: "awesome/adminer"
ports:
- 8080:8080
volumes:
db-data:

View file

@ -0,0 +1,5 @@
version: "3.9"
services:
postgres:
image: awesome/postgres

View file

@ -0,0 +1,47 @@
services:
frontend:
image: awesome/webapp
networks:
- front-tier
- back-tier
monitoring:
image: awesome/monitoring
networks:
- admin
backend:
networks:
back-tier:
aliases:
- database
admin:
aliases:
- mysql
volumes:
- type: volume
source: db-data
target: /data
volume:
nocopy: true
- type: bind
source: /var/run/postgres/postgres.sock
target: /var/run/postgres/postgres.sock
depends_on:
- monitoring
extends:
service: frontend
ports:
- "8000:5010"
links:
- "db:database"
db:
image: postgres
networks:
front-tier:
back-tier:
admin:
volumes:
db-data: