Skip to content

Commit

Permalink
Use multi-stage build to compile javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
mattupstate committed Feb 1, 2024
1 parent 617ab76 commit c7268ca
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions CI.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,25 @@

async def test():
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:
source = client.host().directory(
source_code = client.host().directory(
".", exclude=[".git", "node_modules", ".venv", "__ci__.py"]
)

javascript = (
client.container()
.from_("node:16.15.0-slim")
.with_workdir("/src")
.with_file("/src/package.json", client.host().file("package.json"))
.with_file(
"/src/package-lock.json", client.host().file("package-lock.json")
)
.with_exec(["npm", "install"])
.with_directory("/src", source_code)
.with_exec(["npx", "webpack", "--mode", "production"])
)

await javascript.sync()

redis = client.container().from_("redis:7").with_exposed_port(6379).as_service()

python = (
Expand All @@ -32,7 +48,11 @@ async def test():
.with_exec(["poetry", "install", "--only", "playwright"])
.with_exec(["poetry", "run", "playwright", "install-deps"])
.with_exec(["poetry", "run", "playwright", "install", "chromium"])
.with_directory("/src", source)
.with_directory("/src", source_code)
.with_directory(
"/src/example_app/static/bundles",
javascript.directory("/src/example_app/static/bundles"),
)
.with_exec(["poetry", "install", "--without", "playwright"])
.with_exec(["poetry", "run", "pytest"])
)
Expand Down

0 comments on commit c7268ca

Please sign in to comment.