Docs: add content to 1205: "building container images"
Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
"""#
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user