diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7f919b1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +version: "3" + +services: + db: + image: mariadb + restart: always + ports: + - 8889:3306 + volumes: + - ./db/data/mysql:/var/lib/mysql + environment: + MYSQL_DATABASE: 'kanker' + MYSQL_USER: 'kanker' + MYSQL_PASSWORD: 'kanker' + MYSQL_ROOT_PASSWORD: kanker + + phpmyadmin: + image: phpmyadmin + restart: always + ports: + - 8081:80 + environment: + # - PMA_ARBITRARY=1 + - DB_HOST=db + + php: + build: + args: + user: andreas + uid: 1000 + context: "./php/" + dockerfile: Dockerfile + restart: always + environment: + - DB_HOST=db + - DB_USERNAME=root + ports: + - 9001:9000 + - 8000:8000 + expose: + - 8000 + - 9000 + - 80 + - 443 + # volumes: + # - ./WebsiteAPI:/var/www/html diff --git a/php/Dockerfile b/php/Dockerfile new file mode 100644 index 0000000..f7f9d9d --- /dev/null +++ b/php/Dockerfile @@ -0,0 +1,41 @@ +FROM php:8.1-fpm AS phpbase + +# Arguments defined in docker-compose.yml +ARG user +ARG uid + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + zip \ + unzip + +# Clear cache +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install PHP extensions +RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd + +# Get latest Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Create system user to run Composer and Artisan Commands +RUN useradd -G www-data,root -u $uid -d /home/$user $user +RUN mkdir -p /home/$user/.composer && \ + chown -R $user:$user /home/$user + +# Set working directory +WORKDIR /var/www/html + +USER $user + +COPY ./WebsiteAPI /var/www/html/ + +RUN composer install +RUN composer update + +CMD ["php","artisan","serve","--port=9000","--host=0.0.0.0"] \ No newline at end of file