Docker reorganisation (#6)
* - new file location for docker * update of docker containers * update readme
This commit is contained in:
parent
36a355f604
commit
7e242d5aa2
14
.env.example
14
.env.example
@ -1,10 +1,16 @@
|
||||
USER_UID=1000
|
||||
USER_NAME=laravel
|
||||
|
||||
APP_NAME=KamilCraftAPI
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=kamilcraft-api_db
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=kamilcraft-api
|
||||
DB_USERNAME=kamilcraft-api
|
||||
DB_PASSWORD=password
|
||||
|
||||
EXTERNAL_WEBSERVER_PORT=80
|
||||
CURRENT_UID=1000
|
||||
XDG_CONFIG_HOME=/tmp
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,8 +1,10 @@
|
||||
/.idea
|
||||
/.vscode
|
||||
/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
/.composer
|
||||
.env
|
||||
.env.backup
|
||||
.phpunit.result.cache
|
||||
@ -11,5 +13,3 @@ Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/.idea
|
||||
/.vscode
|
||||
|
34
README.md
34
README.md
@ -10,9 +10,9 @@ API for kamilcraft.com projects
|
||||
|
||||
### Optional
|
||||
|
||||
* PHP 8.0 or later
|
||||
* Composer 2.3.x or later
|
||||
* Nodejs 16.14.x or later
|
||||
* PHP 8.1.x or later
|
||||
* Composer 2.4.x or later
|
||||
* Nodejs 18.14.x or later
|
||||
|
||||
## Preparation and installation
|
||||
|
||||
@ -21,9 +21,9 @@ API for kamilcraft.com projects
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2) Build the image needed for Laravel
|
||||
2) Build the image needed for Laravel and Node.js
|
||||
```shell
|
||||
docker-compose build
|
||||
docker-compose build --no-cache --pull
|
||||
```
|
||||
|
||||
3) Run the images prepared in ``docker-compose.yml``
|
||||
@ -31,11 +31,23 @@ API for kamilcraft.com projects
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
4) Install the dependencies needed for Laravel and Nodejs. \
|
||||
**The installer for Laravel generates the key and migrates the database.** \
|
||||
**In the case of Nodejs, it generates page styles.**
|
||||
4) Install the dependencies needed for Laravel and Nodejs
|
||||
```shell
|
||||
docker-compose exec laravel install
|
||||
docker-compose exec -u "$(id -u):$(id -g)" php composer install
|
||||
```
|
||||
|
||||
5) Go to ``http://localhost/dashboard`` in your browser.
|
||||
```shell
|
||||
docker-compose run --rm -u "$(id -u):$(id -g)" npm install
|
||||
```
|
||||
|
||||
5) Key and data generation
|
||||
```shell
|
||||
docker-compose exec -u "$(id -u):$(id -g)" php php artisan key:generate
|
||||
```
|
||||
```shell
|
||||
docker-compose exec -u "$(id -u):$(id -g)" php php artisan migrate:fresh --seed
|
||||
```
|
||||
```shell
|
||||
docker-compose run --rm -u "$(id -u):$(id -g)" npm run dev
|
||||
```
|
||||
|
||||
6) Go to ``http://localhost/dashboard`` in your browser.
|
||||
|
@ -1,27 +0,0 @@
|
||||
FROM php:8.0-fpm
|
||||
|
||||
ARG USER_UID
|
||||
ARG USER_NAME
|
||||
ENV COMPOSER_HOME=/home/$USER_NAME/.composer
|
||||
|
||||
RUN useradd -G www-data,root -u $USER_UID -d /home/$USER_NAME $USER_NAME
|
||||
RUN mkdir -p /home/$USER_NAME/.composer && \
|
||||
chown $USER_NAME:$USER_NAME -R /home/$USER_NAME
|
||||
RUN set -eux \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install git zip unzip dos2unix -y
|
||||
RUN curl -sS https://getcomposer.org/installer \
|
||||
| php -- --version=2.3.5 --install-dir=/usr/local/bin --filename=composer
|
||||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
|
||||
RUN set -eux \
|
||||
&& apt-get install nodejs -y
|
||||
RUN npm install --global npm@latest
|
||||
|
||||
COPY ./install.sh /usr/local/bin/install
|
||||
RUN dos2unix /usr/local/bin/install \
|
||||
&& chmod +x /usr/local/bin/install
|
||||
|
||||
USER $USER_UID
|
||||
|
||||
EXPOSE 9000
|
@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -d "vendor" ] && [ -f "composer.json" ]; then
|
||||
echo ""
|
||||
echo "########################################"
|
||||
echo "# vendor directory not found... #"
|
||||
echo "########################################"
|
||||
composer install \
|
||||
&& php artisan key:generate
|
||||
|
||||
if [ ! -f "database/database.sqlite" ]; then
|
||||
touch database/database.sqlite
|
||||
fi
|
||||
|
||||
php artisan migrate:fresh --seed
|
||||
fi
|
||||
|
||||
if [ ! -d "node_modules" ] && [ -f "package.json" ]; then
|
||||
echo ""
|
||||
echo "########################################"
|
||||
echo "# node_modules directory not found... #"
|
||||
echo "########################################"
|
||||
npm install
|
||||
npm run dev
|
||||
fi
|
||||
|
||||
echo "$@"
|
||||
exec "$@"
|
@ -6,28 +6,67 @@ services:
|
||||
container_name: kamilcraft-api_www
|
||||
working_dir: /application
|
||||
ports:
|
||||
- "80:80"
|
||||
- ${EXTERNAL_WEBSERVER_PORT:-80}:80
|
||||
volumes:
|
||||
- ./environment/dev/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||
- .:/application
|
||||
- ./config/docker/dev/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||
links:
|
||||
- laravel
|
||||
networks:
|
||||
- localnet
|
||||
- kamilcraft
|
||||
depends_on:
|
||||
- php
|
||||
- db
|
||||
|
||||
laravel:
|
||||
build:
|
||||
args:
|
||||
USER_UID: ${USER_UID}
|
||||
USER_NAME: ${USER_NAME}
|
||||
context: ./config/docker/dev/laravel
|
||||
container_name: kamilcraft-api_laravel
|
||||
working_dir: /application
|
||||
volumes:
|
||||
- .:/application
|
||||
networks:
|
||||
- localnet
|
||||
php:
|
||||
build:
|
||||
context: environment/dev/php
|
||||
container_name: kamilcraft-api_php
|
||||
working_dir: /application
|
||||
user: ${CURRENT_UID:-1000}
|
||||
volumes:
|
||||
- .:/application
|
||||
- ./environment/dev/php/php.ini:/usr/local/etc/php/conf.d/php.ini
|
||||
networks:
|
||||
- kamilcraft
|
||||
extra_hosts:
|
||||
- host.docker.internal:host-gateway
|
||||
restart: unless-stopped
|
||||
|
||||
npm:
|
||||
build:
|
||||
context: environment/dev/npm
|
||||
container_name: kamilcraft-api_node
|
||||
working_dir: /application
|
||||
entrypoint: [ 'npm' ]
|
||||
ports:
|
||||
- '3000:3000'
|
||||
- '3001:3001'
|
||||
volumes:
|
||||
- .:/application
|
||||
networks:
|
||||
- kamilcraft
|
||||
|
||||
db:
|
||||
image: mysql:8.0
|
||||
container_name: kamilcraft-api_db
|
||||
ports:
|
||||
- '${DB_PORT}:3306'
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
|
||||
MYSQL_DATABASE: '${DB_DATABASE}'
|
||||
MYSQL_USER: '${DB_USERNAME}'
|
||||
MYSQL_PASSWORD: '${DB_PASSWORD}'
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
||||
volumes:
|
||||
- 'mysql-db-data:/var/lib/mysql'
|
||||
networks:
|
||||
- kamilcraft
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
localnet:
|
||||
kamilcraft:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
mysql-db-data:
|
||||
name: ib-mysql-data
|
||||
driver: local
|
||||
|
@ -9,7 +9,7 @@ server {
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass laravel:9000;
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
3
environment/dev/npm/Dockerfile
Normal file
3
environment/dev/npm/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM node:18-alpine
|
||||
|
||||
RUN npm install -g npm@latest
|
34
environment/dev/php/Dockerfile
Normal file
34
environment/dev/php/Dockerfile
Normal file
@ -0,0 +1,34 @@
|
||||
FROM php:8.1-fpm-alpine
|
||||
|
||||
ARG XDEBUG_VERSION=3.1.6
|
||||
ARG INSTALL_XDEBUG=false
|
||||
|
||||
ARG COMPOSER_VERSION=2.4.4
|
||||
ENV COMPOSER_HOME=/application/.composer
|
||||
ENV COMPOSER_MEMORY_LIMIT=-1
|
||||
|
||||
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
apk --no-cache add $PHPIZE_DEPS \
|
||||
&& pecl install xdebug-${XDEBUG_VERSION} \
|
||||
&& docker-php-ext-enable xdebug \
|
||||
;fi
|
||||
|
||||
RUN apk update && apk upgrade \
|
||||
&& apk add --no-cache pcre-dev $PHPIZE_DEPS \
|
||||
icu-dev \
|
||||
zip \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
&& curl -sS https://getcomposer.org/installer | php -- --version="${COMPOSER_VERSION}" --install-dir=/usr/local/bin --filename=composer \
|
||||
&& pecl install redis \
|
||||
&& docker-php-ext-install \
|
||||
mysqli \
|
||||
pdo \
|
||||
pdo_mysql \
|
||||
zip \
|
||||
gd \
|
||||
bcmath \
|
||||
&& docker-php-ext-configure \
|
||||
zip \
|
||||
&& docker-php-ext-enable \
|
||||
redis
|
9
environment/dev/php/php.ini
Normal file
9
environment/dev/php/php.ini
Normal file
@ -0,0 +1,9 @@
|
||||
[PHP]
|
||||
memory_limit = 1G
|
||||
|
||||
[xdebug]
|
||||
xdebug.client_host=host.docker.internal
|
||||
xdebug.client_port=9003
|
||||
xdebug.mode=debug
|
||||
xdebug.start_with_request=yes
|
||||
xdebug.log_level=0
|
Loading…
x
Reference in New Issue
Block a user