Coder Social home page Coder Social logo

bash-3.2$ echo "Image ***/code:a494d90af6f3ed3c08ee4f29d345b3b9d8769722 is missing the `service` label" && exit 1 bash: service: command not found Image ***/code:a494d90af6f3ed3c08ee4f29d345b3b9d8769722 is missing the label exit about kamal HOT 10 CLOSED

dorianmariecom avatar dorianmariecom commented on August 29, 2024
bash-3.2$ echo "Image ***/code:a494d90af6f3ed3c08ee4f29d345b3b9d8769722 is missing the `service` label" && exit 1 bash: service: command not found Image ***/code:a494d90af6f3ed3c08ee4f29d345b3b9d8769722 is missing the label exit

from kamal.

Comments (10)

wenderjean avatar wenderjean commented on August 29, 2024

How does your deploy.yml look like?

from kamal.

dorianmariecom avatar dorianmariecom commented on August 29, 2024

Here it is, hope that helps:

service: code
image: dorianmariecom/code
healthcheck:
  cmd: /bin/true
builder:
  remote:
    arch: amd64
    ssh: [email protected]
servers:
  web:
    hosts:
      - 164.92.135.114
    labels:
      traefik.http.routers.code.rule: Host(`code.dorianmarie.com`)
      traefik.http.routers.code_secure.entrypoints: websecure
      traefik.http.routers.code_secure.rule: Host(`code.dorianmarie.com`)
      traefik.http.routers.code_secure.tls.certresolver: letsencrypt
      traefik.http.routers.code_secure.tls: true
registry:
  username:
    - KAMAL_REGISTRY_USERNAME
  password:
    - KAMAL_REGISTRY_PASSWORD
env:
  clear:
    HOST: code.dorianmarie.com
    BASE_URL: https://code.dorianmarie.com
  secret:
    - RAILS_MASTER_KEY
    - POSTGRES_PASSWORD
    - DATABASE_URL
traefik:
  options:
    publish:
      - "443:443"
    volume:
      - "/letsencrypt/acme.json:/letsencrypt/acme.json"
  args:
    entryPoints.web.address: ":80"
    entryPoints.websecure.address: ":443"
    entryPoints.web.http.redirections.entryPoint.to: websecure
    entryPoints.web.http.redirections.entryPoint.scheme: https
    entryPoints.web.http.redirections.entrypoint.permanent: true
    certificatesResolvers.letsencrypt.acme.email: "[email protected]"
    certificatesResolvers.letsencrypt.acme.storage: "/letsencrypt/acme.json"
    certificatesResolvers.letsencrypt.acme.httpchallenge: true
    certificatesResolvers.letsencrypt.acme.httpchallenge.entrypoint: web
accessories:
  db:
    image: postgres:16.1
    host: 164.92.135.114
    port: 5432
    env:
      clear:
        POSTGRES_USER: code
        POSTGRES_DB: code_production
      secret:
        - POSTGRES_PASSWORD
    directories:
      - data:/var/lib/postgresql/data

from kamal.

acidtib avatar acidtib commented on August 29, 2024

hi @dorianmariecom how is the image being generated? using kamal deploy or are you using a github action workflow to build the image and then doing something like kamal deploy --skip-push --version=${{ github.sha }} to deploy?

from kamal.

dorianmariecom avatar dorianmariecom commented on August 29, 2024

The error was because I didn't have LABEL service="code" in my Dockerfile

Dockerfile

FROM debian:bullseye-slim as base
ENV BUNDLER_VERSION="2.5.5" \
    BUNDLE_DEPLOYMENT="1" \
    BUNDLE_PATH="/usr/local/bundle" \
    BUNDLE_WITHOUT="development" \
    NODE_VERSION="20.11.0" \
    NPM_VERSION="10.4.0" \
    RAILS_ENV="production" \
    RUBY_INSTALL_VERSION="0.9.3" \
    RUBY_VERSION="3.3.0" \
    YARN_VERSION="1.22.19"

ENV PATH="/opt/rubies/ruby-${RUBY_VERSION}/bin:/usr/local/node/bin:${PATH}"

RUN apt-get update && \
    apt-get install -y \
        autoconf \
        build-essential \
        curl \
        fish \
        git \
        libpq-dev \
        libvips \
        pandoc \
        pkg-config \
        postgresql-client \
        vim \
        wget

RUN wget "https://github.com/postmodern/ruby-install/releases/download/v${RUBY_INSTALL_VERSION}/ruby-install-${RUBY_INSTALL_VERSION}.tar.gz"
RUN tar -xzvf "ruby-install-${RUBY_INSTALL_VERSION}.tar.gz"

WORKDIR "ruby-install-${RUBY_INSTALL_VERSION}"

RUN make install
RUN ruby-install -p https://github.com/ruby/ruby/pull/9371.diff ruby "${RUBY_VERSION}"

WORKDIR /rails

RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/
RUN /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node
RUN npm install -g "yarn@${YARN_VERSION}"

COPY Gemfile Gemfile.lock ./

RUN gem install bundler -v "${BUNDLER_VERSION}"
RUN bundle install

COPY package.json yarn.lock ./

RUN yarn install --frozen-lockfile

COPY . .

RUN HOST=example.com \
    BASE_URL=https://example.com \
    RAILS_MASTER_KEY_DUMMY=1 \
    SECRET_KEY_BASE_DUMMY=1 \
    ./bin/rails assets:precompile

ENTRYPOINT ["/rails/bin/docker-entrypoint"]

EXPOSE 3000
CMD ["./bin/rails", "server"]
LABEL service="code"

.github/workflows/ci.yml

name: CI
on: push
jobs:
  brakeman:
    name: Brakeman
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - run: sudo apt-get install -y pandoc
      - run: bin/brakeman -A -q --color
  bundler-audit:
    name: Bundler Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - run: bin/bundler-audit
  importmap-audit:
    name: Importmap Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - run: bin/importmap audit
  importmap-outdated:
    name: Importmap Outdated
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - run: bin/importmap outdated
  rspec:
    name: RSpec
    runs-on: ubuntu-latest
    env:
      RAILS_ENV: test
      PGHOST: localhost
      PGUSER: postgres
      PGPASSWORD: password
      POSTGRES_HOST: localhost
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      RAILS_MASTER_KEY: ${{secrets.TEST_RAILS_MASTER_KEY}}
    services:
      postgres:
        image: postgres:latest
        ports: ["5432:5432"]
        env:
          RAILS_ENV: test
          PGHOST: localhost
          PGUSER: postgres
          PGPASSWORD: password
          POSTGRES_HOST: localhost
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: password
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.3.0
          bundler-cache: true
      - uses: actions/setup-node@v4
        with:
          node-version: 20.11.0
          cache: 'yarn'
      - run: yarn install --frozen-lockfile --immutable --ignore-engines
      - run: sudo apt-get -yqq install libpq-dev pandoc
      - run: bin/rails db:create db:schema:load
      - run: bin/rails assets:precompile
      - run: bin/rspec
  rubocop:
    name: Rubocop
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - run: bin/rubocop
  yarn-audit:
    name: Yarn Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: yarn audit
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    needs:
      - brakeman
      - bundler-audit
      - importmap-audit
      - importmap-outdated
      - rspec
      - rubocop
      - yarn-audit
    steps:
      - uses: actions/checkout@v4
      - uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{secrets.SSH_PRIVATE_KEY}}
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          username: ${{secrets.KAMAL_REGISTRY_USERNAME}}
          password: ${{secrets.KAMAL_REGISTRY_PASSWORD}}
      - uses: docker/build-push-action@v5
        with:
          context: .
          cache-from: type=gha
          cache-to: type=gha,mode=max
          push: true
          tags: ${{github.repository}}:${{github.sha}}
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.3.0
          bundler-cache: true
      - run: gem install kamal
      - run: kamal lock release
        if: github.ref == 'refs/heads/main'
      - run: kamal deploy --skip-push
        env:
          KAMAL_REGISTRY_USERNAME: ${{secrets.KAMAL_REGISTRY_USERNAME}}
          KAMAL_REGISTRY_PASSWORD: ${{secrets.KAMAL_REGISTRY_PASSWORD}}
          RAILS_MASTER_KEY: ${{secrets.PRODUCTION_RAILS_MASTER_KEY}}
          POSTGRES_PASSWORD: ${{secrets.POSTGRES_PASSWORD}}
          DATABASE_URL: ${{secrets.DATABASE_URL}}
        if: github.ref == 'refs/heads/main'

from kamal.

wenderjean avatar wenderjean commented on August 29, 2024

@dorianmariecom It should be working now but you can also label your image during image build with docker build --label "service=code" avoiding the need of adding this dependency to your Dockerfile. It should be possible to do a similar thing using docker/setup-buildx-action, look

https://docs.docker.com/build/ci/github-actions/manage-tags-labels/

from kamal.

dorianmariecom avatar dorianmariecom commented on August 29, 2024

The issue is that when the service is not found, it will execute the command service

from kamal.

acidtib avatar acidtib commented on August 29, 2024

@dorianmariecom

        - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          context: .
          file: Dockerfile
          cache-from: type=gha
          cache-to: type=gha,mode=max
          push: true
          labels: service=code
          tags: dorianmariecom/code:latest,dorianmariecom/code:${{ github.sha }}
          secrets: |
            RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_KEY }}

from kamal.

dorianmariecom avatar dorianmariecom commented on August 29, 2024

I'm fine with doing LABEL service="code", just saying that kamal executes a command when it doesn't mean to

from kamal.

wenderjean avatar wenderjean commented on August 29, 2024

You error in fact came from this validation https://github.com/basecamp/kamal/blob/main/lib/kamal/commands/builder/base.rb#L24

from kamal.

dorianmariecom avatar dorianmariecom commented on August 29, 2024

Made the change in #696

from kamal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.