laravel #1
11
.env.example
11
.env.example
@ -0,0 +1,11 @@
|
|||||||
|
PROJECT_NAME=js-manager
|
||||||
|
|
||||||
|
NGINX_PORT=8010
|
||||||
|
|
||||||
|
DB_CONNECTION=pgsql
|
||||||
|
DB_HOST=postgres
|
||||||
|
DB_PORT=5433
|
||||||
|
DB_DATABASE=js-manager
|
||||||
|
DB_USER=user
|
||||||
|
DB_PASSWORD=password
|
||||||
|
DB_ROOT_PASSWORD=init
|
||||||
28
Makefile
Normal file
28
Makefile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
up: docker-up
|
||||||
|
down: docker-down
|
||||||
|
init: docker-down-clear docker-pull docker-build docker-up app-init app-db-seed
|
||||||
|
|
||||||
|
docker-up:
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
docker-down:
|
||||||
|
docker compose down --remove-orphans
|
||||||
|
|
||||||
|
docker-down-clear:
|
||||||
|
docker compose down -v --remove-orphans
|
||||||
|
|
||||||
|
docker-pull:
|
||||||
|
docker compose pull
|
||||||
|
|
||||||
|
docker-build:
|
||||||
|
docker compose build
|
||||||
|
|
||||||
|
app-init:
|
||||||
|
docker compose run --rm php composer install
|
||||||
|
docker compose run --rm php chown root:www-data -R storage/
|
||||||
|
docker compose run --rm php chmod 777 -R storage/
|
||||||
|
docker compose run --rm php cp .env.example .env
|
||||||
|
docker compose run --rm php php artisan key:generate
|
||||||
|
|
||||||
|
app-db-seed:
|
||||||
|
docker compose run --rm php-cli php artisan migrate --seed
|
||||||
84
compose.yml
Normal file
84
compose.yml
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
services:
|
||||||
|
redis:
|
||||||
|
container_name: ${PROJECT_NAME}-redis-local
|
||||||
|
image: redis:latest
|
||||||
|
ports:
|
||||||
|
- '6379:6379'
|
||||||
|
networks:
|
||||||
|
redis_net:
|
||||||
|
aliases:
|
||||||
|
- redis
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
php:
|
||||||
|
container_name: ${PROJECT_NAME}-backend-local
|
||||||
|
build:
|
||||||
|
context: ./docker/php
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
- UID=${UID:-1000}
|
||||||
|
- GID=${GID:-1000}
|
||||||
|
- USER=${USER-laravel}
|
||||||
|
volumes:
|
||||||
|
- ./src:/app
|
||||||
|
working_dir: /app
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
back_net:
|
||||||
|
aliases:
|
||||||
|
- backend
|
||||||
|
redis_net:
|
||||||
|
aliases:
|
||||||
|
- backend
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
container_name: ${PROJECT_NAME}-nginx-local
|
||||||
|
build:
|
||||||
|
context: ./docker/nginx
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
- UID=${UID:-1000}
|
||||||
|
- GID=${GID:-1000}
|
||||||
|
- USER=${USER:-laravel}
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- ${NGINX_PORT}:8000
|
||||||
|
volumes:
|
||||||
|
- ./src:/app
|
||||||
|
depends_on:
|
||||||
|
- php
|
||||||
|
networks:
|
||||||
|
back_net:
|
||||||
|
aliases:
|
||||||
|
- nginx
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
container_name: ${PROJECT_NAME}-postgress
|
||||||
|
image: postgres:16-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
|
||||||
|
POSTGRES_USER: ${DB_USER}
|
||||||
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
|
POSTGRES_DB: ${DB_DATABASE}
|
||||||
|
networks:
|
||||||
|
back_net:
|
||||||
|
aliases:
|
||||||
|
- postgres
|
||||||
|
ports:
|
||||||
|
- ${DB_PORT}:5432
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- postgres-data:/var/lib/postgresql/data
|
||||||
|
- .docker/postgres:/docker-entrypoint-initdb.d/:rw
|
||||||
|
|
||||||
|
networks:
|
||||||
|
back_net:
|
||||||
|
name: back_net_local
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
redis_net:
|
||||||
|
name: redis_net_local
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres-data:
|
||||||
25
docker/nginx/Dockerfile
Normal file
25
docker/nginx/Dockerfile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
FROM nginx:stable-alpine
|
||||||
|
|
||||||
|
# environment arguments
|
||||||
|
ARG UID
|
||||||
|
ARG GID
|
||||||
|
ARG USER
|
||||||
|
|
||||||
|
ENV UID=${UID}
|
||||||
|
ENV GID=${GID}
|
||||||
|
ENV USER=${USER}
|
||||||
|
|
||||||
|
# Dialout group in alpine linux conflicts with MacOS staff group's gid, whis is 20. So we remove it.
|
||||||
|
RUN delgroup dialout
|
||||||
|
|
||||||
|
# Creating user and group
|
||||||
|
RUN addgroup -g ${GID} --system ${USER}
|
||||||
|
RUN adduser -G ${USER} --system -D -s /bin/sh -u ${UID} ${USER}
|
||||||
|
|
||||||
|
# Modify nginx configuration to use the new user's priviledges for starting it.
|
||||||
|
RUN sed -i "s/user nginx/user '${USER}'/g" /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
# Copies nginx configurations to override the default.
|
||||||
|
ADD ./*.conf /etc/nginx/conf.d/
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
25
docker/nginx/default.conf
Normal file
25
docker/nginx/default.conf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
server {
|
||||||
|
listen 8000;
|
||||||
|
index index.php index.html;
|
||||||
|
root /app/public;
|
||||||
|
|
||||||
|
error_log stderr warn;
|
||||||
|
access_log /dev/stdout main;
|
||||||
|
|
||||||
|
# error_log /var/log/nginx/error.log;
|
||||||
|
# access_log /var/log/nginx/access.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
try_files $uri =404;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
fastcgi_pass php:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
}
|
||||||
42
docker/php/Dockerfile
Normal file
42
docker/php/Dockerfile
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
FROM php:8.4-fpm-alpine
|
||||||
|
|
||||||
|
ARG UID
|
||||||
|
ARG GID
|
||||||
|
ARG USER
|
||||||
|
|
||||||
|
ENV UID=${UID}
|
||||||
|
ENV GID=${GID}
|
||||||
|
ENV USER=${USER}
|
||||||
|
|
||||||
|
RUN delgroup dialout
|
||||||
|
|
||||||
|
RUN addgroup -g ${GID} --system ${USER}
|
||||||
|
RUN adduser -G ${USER} --system -D -s /bin/sh -u ${UID} ${USER}
|
||||||
|
|
||||||
|
RUN sed -i "s/user = www-data/user = ${USER}/g" /usr/local/etc/php-fpm.d/www.conf
|
||||||
|
RUN sed -i "s/group = www-data/group = ${USER}/g" /usr/local/etc/php-fpm.d/www.conf
|
||||||
|
RUN echo "php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
|
||||||
|
|
||||||
|
RUN apk add --no-cache postgresql-libs
|
||||||
|
|
||||||
|
RUN apk add --no-cache --virtual .build-deps \
|
||||||
|
$PHPIZE_DEPS \
|
||||||
|
postgresql-dev \
|
||||||
|
linux-headers
|
||||||
|
|
||||||
|
RUN docker-php-ext-install pdo pgsql pdo_pgsql bcmath
|
||||||
|
|
||||||
|
RUN pecl install redis \
|
||||||
|
&& docker-php-ext-enable redis
|
||||||
|
|
||||||
|
RUN apk del --no-cache .build-deps
|
||||||
|
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
||||||
|
RUN chown -R ${USER}:${USER} /app
|
||||||
|
USER ${USER}
|
||||||
|
|
||||||
|
CMD ["php-fpm", "-y", "/usr/local/etc/php-fpm.conf", "-R"]
|
||||||
3
src/public/index.php
Normal file
3
src/public/index.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
phpinfo();
|
||||||
Loading…
x
Reference in New Issue
Block a user