1

I have a Dockerfile

FROM composer:1.8.5 as build_stage

COPY . /src
WORKDIR /src
RUN composer install


FROM alpine:3.8
RUN apk --no-cache add \
php7 \
php7-mbstring \
php7-session \
php7-openssl \
php7-tokenizer \
php7-json \
php7-pdo \
php7-pdo_pgsql \
php7-pgsql
COPY --from=build_stage /src  /src
RUN ls -al
RUN set -x \
addgroup -g 82 -S www-data \
adduser -u 82 -D -S -G www-data www-data
WORKDIR /src
RUN ls -al
RUN chmod -R 777 storage
RUN sudo chmod +x run.sh
copy ./run.sh /tmp
ENTRYPOINT ["/tmp/run.sh"]

run.sh

#!/bin/sh

cd /app
php artisan migrate:fresh --seed
php artisan serve --host=0.0.0.0

and when I run, I kept getting

enter image description here

How would one go about and debug this further?

halfer
  • 19,824
  • 17
  • 99
  • 186
code-8
  • 54,650
  • 106
  • 352
  • 604

2 Answers2

3
RUN sudo chmod +x run.sh
copy ./run.sh /tmp

You are copying a fresh copy from the build context without execute permission onto /tmp/run.sh. Try to change those command for the following.

RUN chmod +x run.sh
RUN cp run.sh /tmp

Note that sudo isn't needed because you are already as root.

codestation
  • 2,938
  • 1
  • 22
  • 22
2

The issue is in this block:

RUN sudo chmod +x run.sh
copy ./run.sh /tmp
ENTRYPOINT ["/tmp/run.sh"]

You make run.sh executable, then overwrite it with a non-executable version. Switching the order of the two commands should fix it:

COPY ./run.sh /tmp
RUN chmod +x /tmp/run.sh
ENTRYPOINT ["/tmp/run.sh"]
Alassane Ndiaye
  • 4,427
  • 1
  • 10
  • 19