Docs: add content to 1205: "building container images"

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes
2022-04-05 01:04:40 +00:00
parent f3ac279f73
commit 26cbc7dc68
3 changed files with 47 additions and 20 deletions

View File

@@ -5,16 +5,23 @@ import (
"universe.dagger.io/docker"
)
dagger.#Plan & {
client: filesystem: "./src": read: contents: dagger.#FS
// This action builds a docker image from a python app.
// Build steps are defined in native CUE.
#PythonBuild: {
// Source code of the Python application
app: dagger.#FS
actions: build: docker.#Build & {
// Container image
image: _build.output
// Build steps
_build: docker.#Build & {
steps: [
docker.#Pull & {
source: "python:3.9"
},
docker.#Copy & {
contents: client.filesystem."./src".read.contents
contents: app
dest: "/app"
},
docker.#Run & {
@@ -29,3 +36,12 @@ dagger.#Plan & {
]
}
}
// Example usage in a plan
dagger.#Plan & {
client: filesystem: "./src": read: contents: dagger.#FS
actions: build: #PythonBuild & {
app: client.filesystem."./src".read.contents
}
}

View File

@@ -5,21 +5,22 @@ import (
"universe.dagger.io/docker"
)
// This action builds a docker image from a python app.
// Build steps are defined in an inline Dockerfile.
#PythonBuild: docker.#Dockerfile & {
dockerfile: contents: """
FROM python:3.9
COPY . /app
RUN pip install -r /app/requirements.txt
CMD python /app/app.py
"""
}
// Example usage in a plan
dagger.#Plan & {
client: filesystem: "./src": read: contents: dagger.#FS
actions: build: docker.#Dockerfile & {
// This is the context.
actions: build: #PythonBuild & {
source: client.filesystem."./src".read.contents
// Default is to look for a Dockerfile in the context,
// but let's declare it here.
dockerfile: contents: #"""
FROM python:3.9
COPY . /app
RUN pip install -r /app/requirements.txt
CMD python /app/app.py
"""#
}
}