Permission denied issue while trying to run a script inside a container in CircleCI

30 Views Asked by At

Trying to run a wait script in a container in CircleCI with the following configuration:

(Note: the command has debugging added)

eventstore-available:
  build:
    context: "."
    dockerfile: docker/waitfor.dockerfile
  command: sh -c 'which sh && chmod 777 /app/wait-for && whoami && ls -la /app && /app/wait-for http://eventstore-karate:2113/health/live -t 0 -- echo "Eventstore is up!"'
  volumes:
    - "./docker/karate/wait-for:/app/wait-for"
  depends_on:
    eventstore-karate:
      condition: service_started
  networks:
    app-karate: ~

But I keep getting a permission denied issue:

repo-eventstore-available-1  | /bin/sh
repo-eventstore-available-1  | root
repo-eventstore-available-1  | total 12
repo-eventstore-available-1  | drwxr-xr-x  3 root root 4096 Feb 10 16:53 .
repo-eventstore-available-1  | drwxr-xr-x  1 root root 4096 Feb 10 16:53 ..
repo-eventstore-available-1  | drwxrwxrwx  2 root root 4096 Feb 10 16:53 wait-for
repo-eventstore-available-1  | sh: /app/wait-for: Permission denied
repo-eventstore-available-1 exited with code 126

Any idea of what I'm doing wrong?

1

There are 1 best solutions below

0
mumia On

Resolved it by moving the logic to the dockerfile:

FROM alpine:latest

COPY docker/karate/wait-for /app/wait-for

RUN chmod +x /app/wait-for