Skip to content

Config: Build with docker #6

Open
@trykovyura

Description

@trykovyura

Hi, thanks for great tool! Trying to customise build configuration, but found some issues and i need some help.

Use cases

  • Build monorepo with nextjs
  • Respository structure is classic for turborepo
  • Have several apps to build with docker and deploy with serverless container
Image

Build config

name: example

deployment:
  type: [email protected]

containers:
  example-docs:
    src: ./apps/example-docs
    routing:
      domain: dev-docs.example.com
      pathPattern: /*
      pathHealthCheck: /api/health
    environment:
      HELLO: world
    compute:
      type: awsFargateEcs
  example-web:
    src: ./apps/example-web
    compute:
      type: awsFargateEcs
      awsFargateEcs:
        cpu: 256
        memory: 512
    build:
      args: # Optional: Arguments to pass to the build, as a map of key-value pairs. This is useful for passing in build arguments to the Dockerfile, like ssh keys to fetch private dependencies, etc.
        key: value # Example: ARG key=value
      dockerFileString: ./apps/example-web/Dockerfile
    routing:
      domain: dev-web.example.com
      pathPattern: /*
      pathHealthCheck: /api/health
    environment:
      HELLO: world

Build error

When i try to deploy this config - it errors with on serverless deploy

  • Unrecognized key(s): build
{
    "source": "sfcore.analysis.generated.v1",
    "event": {
      "actionSucceeded": false,
      "operatingSystem": "linux",
      "architecture": "x64",
      "cicd": true,
      ...
      "isCompose": false,
      "projectType": "containers",
      "cliOptions": [
        "stage",
        "debug"
      ],
      "source": "[email protected]",
      "actionName": "deploy",
      "configurationFileName": "serverless.containers.yml",
      "resolvers": [],
      "error": {
        "name": "Error",
        "message": "Invalid configuration:\n\n  - Unrecognized key(s): build\n\n",
        "code": "INVALID_CONFIGURATION"
      }
    }
  }

Build error analysis

containers:
  my-container:
    src: ./path/to/container # Required: Path to the container source code.
    compute: # Required: Compute configuration.
    build: # Optional: Build configuration.
    environment: # Optional: Environment variables to pass to the container.
    routing: # Required: Routing configuration.
    dev: # Optional: Development mode configuration
  • Actual
example-web:
    src: ./apps/example-web
    compute:
    build:
      args: # Optional: Arguments to pass to the build, as a map of key-value pairs. This is useful for passing in build arguments to the Dockerfile, like ssh keys to fetch private dependencies, etc.
        key: value # Example: ARG key=value
      dockerFileString: ./apps/example-web/Dockerfile
  • Could not find source code to check - is it opensoured?
  • Main hypothesis - looks like a bug 🐛

Docker examples?

More bugs?

  • hypothesis that dockerFileString -> supposed to be dockerFile as is see in serverless configuration

Proposual for configuration update

Add build context to separate src and context

build:
  args: # Optional: Arguments to pass to the build, as a map of key-value pairs. This is useful for passing in build arguments to the Dockerfile, like ssh keys to fetch private dependencies, etc.
    key: value # Example: ARG key=value
  dockerFileString: # Optional: Dockerfile as a string to use for the container (not recommended, prefer
  context: # Optional: Build context for docker file```

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions