Hello people!
I would like some help building an image and executing a container with docker. I don’t know a whole lot about Docker or about this project.
The docker-compose.yml is the following:
version: '3.7'
services:
webserver-bclinic-v1:
container_name: webserver-bclinic-v1
image: nginx:alpine
build:
context: .
dockerfile: docker/nginx/Dockerfile
depends_on:
- "app-bclinic-v1"
ports:
- 80:80
volumes:
- ./src:/var/www
# networks:
# - api_core_network
app-bclinic-v1:
container_name: app-bclinic-v1
image: php:7.4-fpm-alpine
build:
context: .
dockerfile: docker/app/Dockerfile
environment:
CONTAINER_ROLE: app
volumes:
- ./api:/var/www/
# networks:
# - api_core_network
# networks:
# api_core_network:
# external: true
The Dockerfile is the following:
FROM php:7.4-fpm-alpine
COPY docker/app/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod u+x /usr/local/bin/entrypoint.sh
# Add Repositories
#RUN rm -f /etc/apk/repositories &&\
# echo "http://dl-cdn.alpinelinux.org/alpine/v3.12/main" >> /etc/apk/repositories && \
# echo "http://dl-cdn.alpinelinux.org/alpine/v3.12/community" >> /etc/apk/repositories
# Add Build Dependencies
RUN apk add --update --no-cache --virtual .build-deps
RUN apk add git \
openssh \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
zip \
libxml2-dev \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
oniguruma \
jpegoptim optipng pngquant gifsicle \
bzip2-dev \
freetype \
libpng \
libjpeg-turbo \
unzip \
py3-setuptools
# Add packages sd
RUN apk add --update --no-cache \
nano
# Configure & install PHP extensions
RUN docker-php-ext-install pdo_mysql exif pcntl soap bcmath
#RUN docker-php-ext-configure gd --with-freetype --with-jpeg
#RUN docker-php-ext-install gd
RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd && apk del libpng-dev && docker-php-ext-install zip
# Add Composer
RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV PATH="./vendor/bin:$PATH"
# Add credentials on build
ARG SSH_PRIVATE_KEY
RUN mkdir /root/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa
# Ensure Bitbucket domain is accepted
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
# Ajusta o limite de memoria
COPY docker/app/php.ini /usr/local/etc/php/conf.d/php.ini
# Copy microservice code
COPY src /var/www
# Install Composer dependencies
RUN cd /var/www
# Remove credentials
RUN rm -rf /root/.ssh
# Remove build dependencies create user restore@'%' identified by 'restore123'
RUN apk del -f .build-deps
# Update storage permissions
# RUN chown -R www-data:www-data /var/www/app.data Lucas Commennt
# Setup working directory
WORKDIR /var/www
ENTRYPOINT ["sh /usr/local/bin/entrypoint.sh"]
So, the project owner instruct me to run docker-compose up
. I’m getting the following error:
[+] Running 3/3
- Network v1_default Created 0.8s
- Container app-bclinic-v1 Created 2.1s
- Container webserver-bclinic-v1 Created 0.4s
Attaching to app-bclinic-v1, webserver-bclinic-v1
': No such file or directory can't execute 'sh
So, I’m guessing the problem is with the execution of the entrypoint
but I don’t know where. Here’s the entrypoint.sh
.
#!/usr/bin/env sh
role=${CONTAINER_ROLE:-app}
echo $role
if [ "$role" = "app" ]; then
echo "Running the fpm..."
exec php-fpm
elif [ "$role" = "queue" ]; then
echo "Running the queue..."
/usr/bin/supervisord -c /etc/supervisord.conf
elif [ "$role" = "scheduler" ]; then
while [ true ]
do
php /var/www/artisan schedule:run --verbose --no-interaction &
sleep 60
done
else
echo "Could not match the container role \"$role\""
exit 1
fi
Can anybody help?