【问题标题】:running elixir on buildkite with docker-compose fails with dependencies使用 docker-compose 在 buildkite 上运行 elixir 因依赖关系而失败
【发布时间】:2023-01-19 14:28:50
【问题描述】:

我有以下用于 elixir+phoenix 应用程序的 dockerfile

FROM elixir:latest as build_base

RUN apt-get -y update
RUN apt-get -y install inotify-tools curl

ARG TARGETARCH
RUN if [ ${TARGETARCH} = arm64 ]; then \
    curl -L -o /tmp/dart-sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.54.5/dart-sass-1.54.5-linux-${TARGETARCH}.tar.gz \
;else \
    curl -L -o /tmp/dart-sass.tar.gz https://github.com/sass/dart-sass/releases/download/1.54.5/dart-sass-1.54.5-linux-x64.tar.gz \
;fi
RUN tar -xvf /tmp/dart-sass.tar.gz -C /tmp
RUN mv /tmp/dart-sass/sass /usr/local/bin/sass

RUN mkdir -p /app
WORKDIR /app

COPY mix.* ./

RUN mix local.hex --force
RUN mix archive.install hex phx_new --force
RUN mix local.rebar --force

RUN mix deps.clean --all
RUN mix deps.get
RUN mix --version
RUN mix deps.compile

COPY assets assets
COPY vendor vendor
COPY lib lib
COPY config config
COPY priv priv
COPY test test

RUN mix compile

docker-compose 文件如下所示

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
      target: build_base
    volumes:
      - ./:/app
    ports:
      - "80:80"
    command: mix phx.server

我正在尝试将 docker-compose 作为 buildkite 中构建步骤的一部分运行,这是 buildkite 中步骤的摘录

  - label: "run web"
    key: "web"
    commands:
      - mix phx.server
    plugins:
      - docker-compose#v4.9.0:
          run: web
          config: docker-compose.yml

然而,当运行 web 时,我看到一切正常,包括软件包安装,但是当运行应用程序时,我看到以下错误

web_1   | Unchecked dependencies for environment dev:
web_1   | * telemetry_metrics (Hex package)
web_1   |   the dependency is not available, run "mix deps.get"

列表还在继续,这在我的本地机器上运行良好,只有在 buildkite 上运行时。有没有人知道如何解决这个问题?

【问题讨论】:

    标签: docker-compose elixir buildkite


    【解决方案1】:

    您应该固定执行顺序,在下载依赖项之前不能运行混合任务。在您的本地它可以工作,因为您已经缓存了它。

    RUN mix deps.get
    RUN mix deps.clean --all
    RUN mix deps.compile
    
    RUN mix --version # WHAT FOR?!
    

    【讨论】:

      猜你喜欢
      • 2022-01-03
      • 2019-06-16
      • 2015-04-09
      • 2022-08-11
      • 1970-01-01
      • 1970-01-01
      • 2015-02-26
      • 2023-04-09
      • 2013-12-28
      相关资源
      最近更新 更多