diff --git a/docs/reference/universe/docker/README.md b/docs/reference/universe/docker/README.md new file mode 100644 index 00000000..b465e880 --- /dev/null +++ b/docs/reference/universe/docker/README.md @@ -0,0 +1,107 @@ +--- +sidebar_label: docker +--- + +# dagger.io/docker + +Docker container operations + +```cue +import "dagger.io/docker" +``` + +## docker.#Build + +Build a Docker image from source, using included Dockerfile + +### docker.#Build Inputs + +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*source* | `dagger.#Artifact` |- | + +### docker.#Build Outputs + +_No output._ + +## docker.#Command + +A container image that can run any docker command + +### docker.#Command Inputs + +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*command* | `string` |Command to execute | +|*registries* | `[]` |Image registries | + +### docker.#Command Outputs + +_No output._ + +## docker.#ImageFromDockerfile + +Build a Docker image from the provided Dockerfile contents + +### docker.#ImageFromDockerfile Inputs + +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*dockerfile* | `string` |Dockerfile passed as a string | +|*context* | `dagger.#Artifact` |Build context | + +### docker.#ImageFromDockerfile Outputs + +_No output._ + +## docker.#Pull + +Pull a docker container + +### docker.#Pull Inputs + +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*from* | `string` |Remote ref (example: "index.docker.io/alpine:latest") | + +### docker.#Pull Outputs + +_No output._ + +## docker.#Push + +Push a docker image + +### docker.#Push Inputs + +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*ref* | `string` |Remote ref (example: "index.docker.io/alpine:latest") | +|*source* | `dagger.#Artifact` |Image | + +### docker.#Push Outputs + +_No output._ + +## docker.#Run + +### docker.#Run Inputs + +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*ssh.host* | `string` |ssh host | +|*ssh.user* | `string` |ssh user | +|*ssh.port* | `*22 \| int` |ssh port | +|*ssh.key* | `dagger.#Secret` |private key | +|*ref* | `string` |Image reference (e.g: nginx:alpine) | +|*run.ssh.host* | `string` |ssh host | +|*run.ssh.user* | `string` |ssh user | +|*run.ssh.port* | `*22 \| int` |ssh port | +|*run.ssh.key* | `dagger.#Secret` |private key | +|*run.command* | `"""\n # Run detach container\n OPTS=""\n \n if [ ! -z "$CONTAINER_NAME" ]; then\n \tOPTS="$OPTS --name $CONTAINER_NAME"\n fi\n \n docker container run -d $OPTS "$IMAGE_REF"\n """` |Command to execute | +|*run.env.IMAGE_REF* | `string` |- | +|*run.registries* | `[]` |Image registries | + +### docker.#Run Outputs + +_No output._ diff --git a/docs/reference/universe/docker/compose.md b/docs/reference/universe/docker/compose.md new file mode 100644 index 00000000..97202b74 --- /dev/null +++ b/docs/reference/universe/docker/compose.md @@ -0,0 +1,36 @@ +--- +sidebar_label: compose +--- + +# dagger.io/docker/compose + +```cue +import "dagger.io/docker/compose" +``` + +## compose.#Client + +A container image to run the docker-compose client + +### compose.#Client Inputs + +_No input._ + +### compose.#Client Outputs + +_No output._ + +## compose.#Up + +### compose.#Up Inputs + +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*registries* | `[]` |Image registries | +|*run.command* | `"""\n if [ -n "$DOCKER_HOSTNAME" ]; then\n \tssh -i /key -fNT -o "StreamLocalBindUnlink=yes" -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME"\n \texport DOCKER_HOST="unix://$(pwd)/docker.sock"\n fi\n \n # Extend session duration\n echo "Host *\\nServerAliveInterval 240" \>\> "$HOME"/.ssh/config\n chmod 600 "$HOME"/.ssh/config\n \n # Move compose\n if [ -d "$SOURCE_DIR" ]; then\n \tif [ -f docker-compose.yaml ]; then\n \t\tcp docker-compose.yaml "$SOURCE_DIR"/docker-compose.yaml\n \tfi\n \tcd "$SOURCE_DIR"\n fi\n \n docker-compose build\n docker-compose up -d\n """` |Command to execute | +|*run.package."docker-compose"* | `true` |- | +|*run.registries* | `[]` |Image registries | + +### compose.#Up Outputs + +_No output._ diff --git a/stdlib/.dagger/env/docker-compose-directory/.gitignore b/stdlib/.dagger/env/docker-compose-directory/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-directory/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/docker-compose-directory/plan/cleanup.cue b/stdlib/.dagger/env/docker-compose-directory/plan/cleanup.cue new file mode 100644 index 00000000..a5a0d1bc --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-directory/plan/cleanup.cue @@ -0,0 +1,89 @@ +package compose + +import ( + "strconv" + + "dagger.io/dagger" + "dagger.io/dagger/op" +) + +#CleanupCompose: { + // docker-compose up context + context: dagger.#Artifact + + ssh: { + // ssh host + host: string @dagger(input) + + // ssh user + user: string @dagger(input) + + // ssh port + port: *22 | int @dagger(input) + + // private key + key: dagger.#Secret @dagger(input) + + // fingerprint + fingerprint?: string @dagger(input) + + // ssh key passphrase + keyPassphrase?: dagger.#Secret @dagger(input) + } + + #code: #""" + # Export host + export DOCKER_HOST="unix://$(pwd)/docker.sock" + + # Start ssh agent + eval $(ssh-agent) > /dev/null + ssh-add /key > /dev/null + + ssh -i /key -o "StreamLocalBindUnlink=yes" -fNT -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" || true + + # Down + if [ -d source ]; then + cd /source + fi + + docker-compose down -v + """# + + #up: [ + op.#Load & {from: context}, + + op.#WriteFile & { + content: #code + dest: "/entrypoint.sh" + }, + + op.#Exec & { + always: true + args: [ + "/bin/sh", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/entrypoint.sh", + ] + env: { + DOCKER_HOSTNAME: ssh.host + DOCKER_USERNAME: ssh.user + DOCKER_PORT: strconv.FormatInt(ssh.port, 10) + if ssh.keyPassphrase != _|_ { + SSH_ASKPASS: "/get_passphrase" + DISPLAY: "1" + } + } + mount: { + if ssh.key != _|_ { + "/key": secret: ssh.key + } + if ssh.keyPassphrase != _|_ { + "/passphrase": secret: ssh.keyPassphrase + } + } + }, + ] +} diff --git a/stdlib/.dagger/env/docker-compose-directory/plan/compose.cue b/stdlib/.dagger/env/docker-compose-directory/plan/compose.cue new file mode 100644 index 00000000..f252b14d --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-directory/plan/compose.cue @@ -0,0 +1,31 @@ +package compose + +import ( + "dagger.io/dagger" + "dagger.io/docker" + "dagger.io/docker/compose" +) + +repo: dagger.#Artifact @dagger(input) + +TestCompose: { + up: compose.#Up & { + ssh: { + host: "143.198.64.230" + user: "root" + } + source: repo + } + + verify: docker.#Command & { + ssh: up.run.ssh + command: #""" + docker container ls | grep "api" | grep "Up" + """# + } + + cleanup: #CleanupCompose & { + context: up.run + ssh: verify.ssh + } +} diff --git a/stdlib/.dagger/env/docker-compose-directory/values.yaml b/stdlib/.dagger/env/docker-compose-directory/values.yaml new file mode 100644 index 00000000..7414c4c2 --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-directory/values.yaml @@ -0,0 +1,29 @@ +plan: + module: .dagger/env/docker-compose-directory/plan +name: docker-compose-directory +inputs: + TestCompose.up.ssh.key: + secret: ENC[AES256_GCM,data:54RfK81pTyk8F52munntMtc34t5fMV83HS+4vhnjYeC203t8AX70NbbxTVOizjI/e+jUjvwabDjrFG/fWfvLvm6kZQQQ1ECg0u71oGdDV4avSdx4mR7YEhUN/Xes/jM+B4B4igDdC25Q6u3DPAOA61e8o/Tv9pRKDpgj6ztKweTdK09wLVguHsuAmBs9lhiMOWWRNWSLZL+N3SxQwb+fZc1lUVyI3Xnth6rvComNdEcJszTrz2mMJNUDM9Zw4OvIXEhiTjByOS+5qqkpl0HOzyX1ktAeU63B0a8PkV90ws/bz1/9IFk6w57owbbJQ6iBXDe4+D8rABPqyYB3XbYzoEAT+u2geBV2e31slhTTJK0OSYIyWY+2sE8fPNXmveFeuxGLGQptTkrUqu21Y3ZQpGYuuEzh+YrpBOP3wXV+HYyMo8YDJIKJECIi7QT8V8bkZ7mbqQQU2M5RxU2/fwBf8LTU5ShLJpPu5jL1obUvqxBOZf7tPVL/5cfYVrjDM25UYqKUMc1N4rGawjJrkRGNi7oH3dc32fZHnRu2,iv:Bcw6vL1YSm1J0aAlsuxB3D4VZKc345Tnuh6vxnUcmSk=,tag:A7mxZNoCXQzMkh9yb/Uhvw==,type:str] + repo: + dir: + path: ./docker/compose/testdata +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBmMjkxUitkQUpYWldlMkdo + Y0R4ZEx2ZVV4WTVic3pzaFBGdGJ3emo5T1hzCllyTXVUMEl5SGx2ekM2eEhrMFpj + MS9wcHRrdnFMWUlTdHdLTTNHZElKZkUKLS0tIDFpWWFoY2JZc25nVE9pbXlOMFpS + MG8yM2VtSldVYzRJZnFsNTJMYXUrWTAKoitUeYU7MDClQo5Rvs/CYcZWzU57QrIk + YrCCEjehmguDoZPKlBowtzwTzNTyTBK3x8hjkj655EPnJIw2P86pjg== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-17T13:11:50Z" + mac: ENC[AES256_GCM,data:1x14dBYelWAq3dnOxNVHp/rt2AcKQVejfr/KLuq2PfJqorOO3MD54mBIiX4DVmBak1jzFJ5I4PQxv+7pltHDgYA9NqQaSi6O9zd6c80wKD8NlXDNlLyPpxq1FccX/4yvAyYpxGrvRk0GFbfXpJxWaKE/48Pb0mPQJPdQMYCnA84=,iv:zZsdt2TbExB5c6vsV8PK3yHLfEIICMDjA+lGMJ6rdws=,tag:MHJamBbW+RQ143iAMU5zWQ==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/.dagger/env/docker-compose-mix-context/.gitignore b/stdlib/.dagger/env/docker-compose-mix-context/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-mix-context/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/docker-compose-mix-context/plan/cleanup.cue b/stdlib/.dagger/env/docker-compose-mix-context/plan/cleanup.cue new file mode 100644 index 00000000..1c2d4bce --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-mix-context/plan/cleanup.cue @@ -0,0 +1,89 @@ +package compose + +import ( + "strconv" + + "dagger.io/dagger" + "dagger.io/dagger/op" +) + +#CleanupCompose: { + // docker-compose up context + context: dagger.#Artifact + + ssh: { + // ssh host + host: string @dagger(input) + + // ssh user + user: string @dagger(input) + + // ssh port + port: *22 | int @dagger(input) + + // private key + key: dagger.#Secret @dagger(input) + + // fingerprint + fingerprint?: string @dagger(input) + + // ssh key passphrase + keyPassphrase?: dagger.#Secret @dagger(input) + } + + #code: #""" + # Export host + export DOCKER_HOST="unix://$(pwd)/docker.sock" + + # Start ssh agent + eval $(ssh-agent) > /dev/null + ssh-add /key > /dev/null + + ssh -i /key -o "StreamLocalBindUnlink=yes" -fNT -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" || true + + # Down + if [ -d /source ]; then + cd /source + fi + + docker-compose down -v + """# + + #up: [ + op.#Load & {from: context}, + + op.#WriteFile & { + content: #code + dest: "/entrypoint.sh" + }, + + op.#Exec & { + always: true + args: [ + "/bin/sh", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/entrypoint.sh", + ] + env: { + DOCKER_HOSTNAME: ssh.host + DOCKER_USERNAME: ssh.user + DOCKER_PORT: strconv.FormatInt(ssh.port, 10) + if ssh.keyPassphrase != _|_ { + SSH_ASKPASS: "/get_passphrase" + DISPLAY: "1" + } + } + mount: { + if ssh.key != _|_ { + "/key": secret: ssh.key + } + if ssh.keyPassphrase != _|_ { + "/passphrase": secret: ssh.keyPassphrase + } + } + }, + ] +} diff --git a/stdlib/.dagger/env/docker-compose-mix-context/plan/compose.cue b/stdlib/.dagger/env/docker-compose-mix-context/plan/compose.cue new file mode 100644 index 00000000..15c1f901 --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-mix-context/plan/compose.cue @@ -0,0 +1,46 @@ +package compose + +import ( + "dagger.io/dagger" + "dagger.io/docker" + "dagger.io/docker/compose" +) + +repo: dagger.#Artifact + +TestCompose: { + up: compose.#Up & { + ssh: { + host: "143.198.64.230" + user: "root" + } + source: repo + composeFile: #""" + version: "3" + + services: + api-mix: + build: . + environment: + PORT: 7000 + ports: + - 7000:7000 + + networks: + default: + name: mix-context + """# + } + + verify: docker.#Command & { + ssh: up.run.ssh + command: #""" + docker container ls | grep "api-mix" | grep "Up" + """# + } + + cleanup: #CleanupCompose & { + context: up.run + ssh: verify.ssh + } +} diff --git a/stdlib/.dagger/env/docker-compose-mix-context/values.yaml b/stdlib/.dagger/env/docker-compose-mix-context/values.yaml new file mode 100644 index 00000000..e4f8343e --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-mix-context/values.yaml @@ -0,0 +1,29 @@ +plan: + module: .dagger/env/docker-compose-mix-context/plan +name: docker-compose-mix-context +inputs: + TestCompose.up.ssh.key: + secret: ENC[AES256_GCM,data:PFfUg9ViLTNkVbbAUhSk38H3xJwRj2apsxK/pGkHdYbmzSxtwf10R0HcJuRgHY+D/Q8Wy5qNnhByaVePYqpmu28LAMSERcIDqurDX/pDVgyK9dZKCp6Jq+57mVl+PtkyKkYyp/PKWjVI1W6uMSFjjv53OdfUPmygdpcfRiWq2JXRx/SLQtWtfme0QxUPUNVTEnuvmyfA44mZbah6z270rA0/AZyHF1+AKJpY1Dm4y11D1wTamZkAK45EghG0GcUyRjx/PLyIRYzVumcqCUTLMn7frfxjD5ft44C05hL76KJSBEekmsxytj3v7HCvnULEwtsIhcS0imyu139fe9nHPXhTgkJvP2tKZF8P4e65MjHszTema3SUVegCbl5aavms4Z30vRP0kX/sbUVuDktaPMN2bUSBREmbkRBGOKIRHuDDTEgQBRf9eFIMe3Z/kfYjVYRQPiLc+KUhxwXjs43TYebqS+FwzY757h1gvzqdKmtdHK6KI3agmKbgQCmAnvsJEl7C3qlFso8zTgcT0ei2IGHZ86DstMCQFzRU,iv:SgafW/IIOZyyI7uaccDgmERfmiURKX4Z6UGzbRZ5T2s=,tag:XCa3nBhjGch3MjlHRCG4/w==,type:str] + repo: + dir: + path: ./docker/compose/testdata +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBMSmROdEtUblF3REhwS3hC + bU9ObTE0aWQzdGJzRlB5WjA0UG5nZFFJTEJjClljQWFYYWNQaFozZGRMcWxyT3p3 + Y0ZVUlZISUNlVkxVSVBqY0RRaGxPN3cKLS0tIGhsUTFCK2ljaWZFekVQMlRSRmtD + bEY3N3ZLTFpUNzZVWVBOK3VNRk9hWlUKd9db3j7FqFW4t7TxFyzudKDPTVqr66v2 + KqedhRYCjF4ZozN0H++xQPH24RBRnwc6Uq0Vm38UYv1ozDN2L/l5DA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-17T13:12:17Z" + mac: ENC[AES256_GCM,data:dqszDALkWcBoEZKogzVRGZA/L/5ZUrn872KfcXawx/osd7RZXRNI3DhHN10scX7Mu94yIkFBW0V+TBGseFkA/8uZmgS1AEepVf6Z5GB17/kg7tGiFGJFwNIcc2PqpN+1CvK6SYfo2Ro309wUnt+sCIXEwPn9C5XObaAvje1KnZg=,iv:3Xc75g1OFlp6j+mwWWXfyVPE3gXEnLYGza8FdtQ94zc=,tag:dj4Na2g2KEM2Lz8Ws/op/w==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/.dagger/env/docker-compose-simple/.gitignore b/stdlib/.dagger/env/docker-compose-simple/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-simple/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/docker-compose-simple/plan/cleanup.cue b/stdlib/.dagger/env/docker-compose-simple/plan/cleanup.cue new file mode 100644 index 00000000..3739d449 --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-simple/plan/cleanup.cue @@ -0,0 +1,85 @@ +package compose + +import ( + "strconv" + + "dagger.io/dagger" + "dagger.io/dagger/op" +) + +#CleanupCompose: { + // docker-compose up context + context: dagger.#Artifact + + ssh: { + // ssh host + host: string @dagger(input) + + // ssh user + user: string @dagger(input) + + // ssh port + port: *22 | int @dagger(input) + + // private key + key: dagger.#Secret @dagger(input) + + // fingerprint + fingerprint?: string @dagger(input) + + // ssh key passphrase + keyPassphrase?: dagger.#Secret @dagger(input) + } + + #code: #""" + # Export host + export DOCKER_HOST="unix://$(pwd)/docker.sock" + + # Start ssh agent + eval $(ssh-agent) > /dev/null + ssh-add /key > /dev/null + + ssh -i /key -o "StreamLocalBindUnlink=yes" -fNT -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" || true + + # Down + docker-compose down -v + """# + + #up: [ + op.#Load & {from: context}, + + op.#WriteFile & { + content: #code + dest: "/entrypoint.sh" + }, + + op.#Exec & { + always: true + args: [ + "/bin/sh", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/entrypoint.sh", + ] + env: { + DOCKER_HOSTNAME: ssh.host + DOCKER_USERNAME: ssh.user + DOCKER_PORT: strconv.FormatInt(ssh.port, 10) + if ssh.keyPassphrase != _|_ { + SSH_ASKPASS: "/get_passphrase" + DISPLAY: "1" + } + } + mount: { + if ssh.key != _|_ { + "/key": secret: ssh.key + } + if ssh.keyPassphrase != _|_ { + "/passphrase": secret: ssh.keyPassphrase + } + } + }, + ] +} diff --git a/stdlib/.dagger/env/docker-compose-simple/plan/compose.cue b/stdlib/.dagger/env/docker-compose-simple/plan/compose.cue new file mode 100644 index 00000000..a97505c2 --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-simple/plan/compose.cue @@ -0,0 +1,37 @@ +package compose + +import ( + "dagger.io/docker" + "dagger.io/docker/compose" +) + +TestCompose: { + up: compose.#Up & { + ssh: { + host: "143.198.64.230" + user: "root" + } + composeFile: #""" + version: "3" + + services: + nginx: + image: nginx:alpine + ports: + - 8000:80 + """# + } + + verify: docker.#Command & { + ssh: up.run.ssh + command: #""" + docker container ls | grep "nginx" | grep "Up" + """# + } + + // Can't simply use docker.#Command because we need to keep docker-compose context + cleanup: #CleanupCompose & { + context: up.run + ssh: verify.ssh + } +} diff --git a/stdlib/.dagger/env/docker-compose-simple/values.yaml b/stdlib/.dagger/env/docker-compose-simple/values.yaml new file mode 100644 index 00000000..5bfc5cde --- /dev/null +++ b/stdlib/.dagger/env/docker-compose-simple/values.yaml @@ -0,0 +1,26 @@ +plan: + module: .dagger/env/docker-compose-simple/plan +name: docker-compose-simple +inputs: + TestCompose.up.ssh.key: + secret: ENC[AES256_GCM,data:abxRdizVf/D9A9XI1xnQKaQrwRYHu12Ene3MmyooqxnqLtOB2Y03YtdfL2MAJLB73ulWYAXWOEcefU8+DghnkCQ94EenDNmnbuAJvXOdqgo0g4Uik1jXUpC6D81YQCFQmqTzsNoh0Rom+bKZK8boVVSEyLr7cgjEtAsAfIgns4B0uVe5l5XaHw+vfSXP3hraxZjbXUdv6qPKtkTWzeu2ywvUEzc7zm7XCHXWsZDzuyKaGJThxZu6upiHRuMdsJ7JSNJMdZ9AOAVMTfD0miYFOuj6mdlYshtR+6lWo86i+LKXdILsUi9cerapqvFV+rjN31hS2Y1dY5O0O/rQOhPv7LcbpAKzkQsnY4giKf8oBwfn2v7roA7C+b1P1GeknQZaozckV644mJPLztfukJjhFjZ8qWHkv/jpdetm1FQJSDkBs2o3EqPbZJLFdyvui6g50dNdP48sdzuxONLH8vPwHrkjkUp4QK9mMd/Fhva0G/dgnO49h/pAVqicketnlQnl+V8RUpWAxHVRRAZ4CmGj2M4XtePnPXsTeysi,iv:EftAI98PVgOWaI63T1Isbe0EpjRIxaUYYmAe7i19J8Q=,tag:4OJHMVVfbbY8KNWG4va/pg==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAyMUJoZHN0NVFCd1d1bXUv + ZCtPUmltRmJCcnE3WHhheGRjOE5Yby95Mmd3CmJKTzBQYXNyRHVKcTQrZUNWL3pC + TnNhZmFJeGJCRmJ4UkVMMlZxUnVXV00KLS0tIGN5cWlrdDhGVkVLMlNMNWJVRkEv + ejZLR2dsTFlyQTR4amptL2Npb3R3QTAKpP7FdS2HwfBcCjhHolgDV2aEGII0IUwV + +V3fy0p1JBrhyGif/d2dca7hJGkMv42TgaGy+EHXZWKw+5cbq/XctQ== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-17T11:56:59Z" + mac: ENC[AES256_GCM,data:OPUtKdxQNAB564Zljt7zJ6mITLMpf2qmeGvpMsEGi1Y907wMbBCJ5kgoo1t19nr/gEvyY2zE611dcbs5xEqn47WM1L87VJ+YQOfv2dGFg460LrNGaGgqTS7wxyynnAfRmDHVvIowVps4Qso8QVMOIbbiL/Dyn5ePzoQYQlHhp8s=,iv:XN0T1ukTJRWsvhvRsVUUodkFOfyfVrrV0l3OCQSQ95I=,tag:iK2WvfI+33z7T5p7E/7Tag==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/docker/command.cue b/stdlib/docker/command.cue index 05e24676..e51f1aec 100644 --- a/stdlib/docker/command.cue +++ b/stdlib/docker/command.cue @@ -203,7 +203,7 @@ import ( } "mount": { if ssh == _|_ { - "/var/run/docker.sock": "docker.sock" + "/var/run/docker.sock": from: "docker.sock" } if ssh != _|_ { if ssh.key != _|_ { diff --git a/stdlib/docker/compose/testdata/Dockerfile b/stdlib/docker/compose/testdata/Dockerfile new file mode 100644 index 00000000..25d4c068 --- /dev/null +++ b/stdlib/docker/compose/testdata/Dockerfile @@ -0,0 +1,15 @@ +FROM node:12-alpine + +WORKDIR /app + +COPY package.json package.json + +RUN npm install + +COPY . . + +ENV PORT=8080 + +EXPOSE 8080 + +CMD ["npm", "start"] \ No newline at end of file diff --git a/stdlib/docker/compose/testdata/docker-compose.yaml b/stdlib/docker/compose/testdata/docker-compose.yaml new file mode 100644 index 00000000..908bc744 --- /dev/null +++ b/stdlib/docker/compose/testdata/docker-compose.yaml @@ -0,0 +1,7 @@ +version: "3" + +services: + api: + build: "" + ports: + - "8080:8080" \ No newline at end of file diff --git a/stdlib/docker/compose/testdata/index.ts b/stdlib/docker/compose/testdata/index.ts new file mode 100644 index 00000000..d37fe572 --- /dev/null +++ b/stdlib/docker/compose/testdata/index.ts @@ -0,0 +1,13 @@ +import express from "express"; +import { get } from "env-var"; + + +const app = express(); + +const port: number = get('PORT').required().asPortNumber(); + +app.get('/ping', (req, res) => { + res.status(200).send('pong') +}); + +app.listen(port, '0.0.0.0', () => console.log("Server listen on http://localhost:" + port)); \ No newline at end of file diff --git a/stdlib/docker/compose/testdata/package.json b/stdlib/docker/compose/testdata/package.json new file mode 100644 index 00000000..c2be41f2 --- /dev/null +++ b/stdlib/docker/compose/testdata/package.json @@ -0,0 +1,22 @@ +{ + "name": "test", + "version": "1.0.0", + "description": "A simple api", + "main": "index.ts", + "scripts": { + "build": "tsc", + "start": "ts-node index.ts", + "test": "test" + }, + "author": "Tom Chauveau", + "license": "ISC", + "devDependencies": { + "ts-node": "^8.9.1", + "typescript": "^3.8.3" + }, + "dependencies": { + "@types/express": "^4.17.6", + "env-var": "^6.1.1", + "express": "^4.17.1" + } +} diff --git a/stdlib/docker/compose/testdata/tsconfig.json b/stdlib/docker/compose/testdata/tsconfig.json new file mode 100644 index 00000000..98907427 --- /dev/null +++ b/stdlib/docker/compose/testdata/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "sourceMap": true, + "outDir": "dist", + "strict": true, + "lib": [ + "esnext", + "dom" + ], + "esModuleInterop": true + } +} diff --git a/stdlib/universe.bats b/stdlib/universe.bats index 90548f1b..dba3f033 100644 --- a/stdlib/universe.bats +++ b/stdlib/universe.bats @@ -70,6 +70,18 @@ setup() { assert_failure } +@test "docker compose: simple" { + dagger -e docker-compose-simple up +} + +@test "docker compose: directory" { + dagger -e docker-compose-directory up +} + +@test "docker compose: mix-context" { + dagger -e docker-compose-mix-context up +} + @test "docker run: ssh" { dagger -e docker-run-ssh up } diff --git a/tests/stdlib/docker/compose/simple/.dagger/env/default/state/computed.json b/tests/stdlib/docker/compose/simple/.dagger/env/default/state/computed.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/tests/stdlib/docker/compose/simple/.dagger/env/default/state/computed.json @@ -0,0 +1 @@ +{}