buildkite-plugins / docker-compose-buildkite-plugin

🐳⚡️ Run build scripts, and build + push images, w/ Docker Compose
MIT License
171 stars 138 forks source link

Docker Compose Plugin Error: No Build or Run Options Specified in Buildkite Pipeline #414

Closed oh-tarnished closed 8 months ago

oh-tarnished commented 8 months ago

Description

I am encountering an issue with the Docker Compose plugin in Buildkite. Despite setting up a common attribute for Docker Compose configuration, the plugin fails with an error indicating that no build or run options are specified.

Configuration

Pipeline.yaml


env:
PROJECT_ENVIRONMENT: buildkite 
DRY_RUN: false

common:

steps:

Error Log

Docker Compose plugin error
[2023-12-19T11:26:11Z] No build or run options were specified
[2023-12-19T11:26:11Z] 🚨 Error: The command exited with status 1
[2023-12-19T11:26:11Z] user command error: The plugin docker-compose command hook exited with status 1

Questions

toote commented 8 months ago

@oh-tarnished as the error states, none of the common anchors have a run or build configuration for the plugin. Based on the step's configuraton, I assume that you are trying to run the command specified in the container, so you would need to add a run element to the plugin's configuration with the name of the service you want to run the script on.

How can I set the workdir for the Docker Compose plugin while keeping the common attribute functional? since i need to change the directory to run the commands.

That depends on how or why the workdir would need to change. If it is depending on the architecture, you could have different workdir configurations for each common element. If not, let us know exactly your scenario and we can further troubleshoot.

oh-tarnished commented 8 months ago

Hey @toote, Thank you for the docker-compose command issue (fixed it). So our CI is with @bazelbuild, and there are multiple workspaces where the CI needs to run on hence the workdir needs to be changed else bazel throws an error. The commands needs to be executed in the dir of the project. and we have multiple of them.

toote commented 8 months ago

@oh-tarnished interesting usecase. I am not too familiar with Bazel builds but you could always change the directory in your script being run instead of relying on the pipeline to specify the folder correctly. If your script does not have enough information for that, you could use an environment variable set at the pipeline, step or plugin level to pass through to the script instead. Alternatively, you can always remove the workdir option from the plugin to have the command be run in the container's default directory (assuming that it is set correctly in the corresponding Dockerfile when the image is built).

What do you think?

oh-tarnished commented 8 months ago

@toote Well yeah that works, thank you. It was my bad i was trying to do it wrong. fixed it.

Right now i'm facing another issue with docker-compose using cached images.

Context

Following up on the previously reported issue, we are still experiencing problems with Docker image tagging and pushing in our Buildkite pipeline. The error persists when trying to tag and push images to Docker Hub, particularly with our multi-architecture setup (x86 and arm64).

Error Message

[2023-12-21T06:46:07Z] $ docker tag buildkite018c8b1e0f8c4010810dd67ea35fab8d_tryoutlab_workspace tryoutlab_workspace:dockerhub/tryoutlab:tryoutlab-workspace-latest
[2023-12-21T06:46:07Z] Error response from daemon: No such image: buildkite018c8b1e0f8c4010810dd67ea35fab8d_tryoutlab_workspace:latest
[2023-12-21T06:46:07Z] 🚨 Error: The command exited with status 1

Updated pipeline.yaml

# Buildkite Pipeline Configuration for tryoutlab
env:
  PROJECT_ENVIRONMENT: buildkite
  DRY_RUN: false

common:
 - docker_workspace: &run_docker_workspace
    docker-compose#v4.16.0:
      run: tryoutlab_workspace
      config: .buildkite/docker-compose.yaml
      workdir: /workspace
      image-name: tryoutlab-build-${BUILDKITE_BRANCH}
      image-repository: dockerhub/tryoutlab
      cache-from:
        - tryoutlab_workspace:dockerhub/tryoutlab:tryoutlab-workspace-latest
        - tryoutlab_workspace:dockerhub/tryoutlab:tryoutlab-workspace-${BUILDKITE_BRANCH}

steps:
  - label: ":sweating: Random Check ✨"
    command: .buildkite/steps/blah.sh
    plugins: *docker_workspace

  - label: ":broom: Cleanup: Push :buildkite: Cache Images to :docker: Hub"
    plugins:
      - docker-compose#v4.16.0:
          config: .buildkite/docker-compose.yaml
          push:
          - tryoutlab_workspace:dockerhub/tryoutlab:tryoutlab-workspace-latest
          - tryoutlab_workspace:dockerhub/tryoutlab:tryoutlab-workspace-${BUILDKITE_BRANCH}

Further Assistance Needed

Looking forward to any further advice or solutions to this persisting issue.

pzeballos commented 8 months ago

Hey @oh-tarnished! can you send that question to Support? as is not an issue related specifically with the plugin. Thanks!