Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
README.md
.env
Dockerfile
docker-compose.yml
docker-compose.dev.yml
docker-compose.core.yml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docker-compose.core.yml
docker-compose.core.yml
docker-compose.prod.yml

.gitignore
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
DC := docker compose
DC := docker compose -f ./docker-compose.core.yml

all: set_app_host up
all: set_app_host dev

up:
$(DC) up --build
dev:
$(DC) -f ./docker-compose.dev.yml up --build

prod: set_app_host
$(DC) -f ./docker-compose.prod.yml up --build

down:
$(DC) down
Expand All @@ -14,9 +17,10 @@ fclean: down
docker system prune -af --volumes
rm -rf websocket/node_modules
rm -rf frontend/node_modules
rm -rf frontend/dist
rm -rf api/storage/photos/*

re: fclean up
re: fclean dev

set_app_host:
@if [ "$(wildcard .env)" = "" ]; then \
Expand Down
16 changes: 16 additions & 0 deletions api/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM composer:2.0

WORKDIR /app

RUN apk add --no-cache \
php8-pdo \
php8-pdo_mysql \
php8-mysqli \
mysql-client \
libpng-dev \
php8-fpm

RUN docker-php-ext-install pdo pdo_mysql gd

COPY --chmod=777 ./entrypoint_docker.prod.sh .
ENTRYPOINT ["sh", "entrypoint_docker.prod.sh"]
28 changes: 14 additions & 14 deletions api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions api/entrypoint_docker.prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
composer require

upload_max_filesize=240M
post_max_size=50M
max_execution_time=100
max_input_time=223

for key in upload_max_filesize post_max_size max_execution_time max_input_time
do
sed -i "s/^\($key\).*/\1 $(eval echo = \${$key})/" /usr/local/etc/php/php.ini-development
done

cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini

sed -i 's|^listen =.*|listen = 0.0.0.0:9000|' /etc/php8/php-fpm.d/www.conf

composer migrate

php-fpm8 -F
35 changes: 1 addition & 34 deletions docker-compose.yml → docker-compose.core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,10 @@ services:
networks:
- matchaNetwork

api:
build:
context: ./api/
dockerfile: Dockerfile
container_name: api
restart: always
volumes:
- api:/app
ports:
- 3000:3000
networks:
- matchaNetwork
depends_on:
mysql:
condition: service_healthy
env_file:
- ./.env

websocket:
build:
context: ./websocket/
# image: node:22.11
container_name: websocket
restart: always
volumes:
Expand All @@ -64,22 +47,6 @@ services:
depends_on:
- mysql

frontend:
build:
context: ./frontend/
container_name: frontend
restart: always
volumes:
- frontend:/app
expose:
- '1212'
ports:
- 1212:1212
networks:
- matchaNetwork
depends_on:
- mysql

volumes:
frontend:
driver: local
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
frontend:
image: node:22.11
container_name: frontend
restart: always
volumes:
- frontend:/app
expose:
- '1212'
ports:
- 1212:1212
networks:
- matchaNetwork
working_dir: /app
command: sh -c "npm install && npm run dev"

api:
build:
context: ./api/
dockerfile: Dockerfile
container_name: api
restart: always
volumes:
- api:/app
ports:
- 3000:3000
networks:
- matchaNetwork
depends_on:
mysql:
condition: service_healthy
env_file:
- ./.env
52 changes: 52 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
services:
nginx:
build:
context: .
dockerfile: ./nginx/Dockerfile
container_name: nginx
restart: always
ports:
- "1212:1212"
networks:
- matchaNetwork



nginx_api:
image: nginx:alpine
container_name: nginx_api
restart: always
volumes:
- api:/app
- ./nginx/api.conf:/etc/nginx/conf.d/api.conf
ports:
- "3000:3000"
networks:
- matchaNetwork
depends_on:
- api
command: /bin/sh -c "
cp -R /app/* /usr/share/nginx/html/ &&
chown -R nginx:nginx /usr/share/nginx/html/ &&
chmod -R 755 /usr/share/nginx/html/ &&
nginx -g 'daemon off;'"

api:
build:
context: ./api/
dockerfile: Dockerfile.prod
container_name: api
restart: always
volumes:
- api:/app
# ports:
# - 3000:3000
expose:
- 9000
networks:
- matchaNetwork
depends_on:
mysql:
condition: service_healthy
env_file:
- ./.env
5 changes: 0 additions & 5 deletions frontend/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/entrypoint_docker.sh

This file was deleted.

15 changes: 15 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:22.11 AS builder

WORKDIR /app

COPY ./frontend/ ./

RUN npm install && npm run build

FROM nginx:alpine

COPY --from=builder /app/dist /usr/share/nginx/html

COPY ./nginx/conf.d /etc/nginx/conf.d

CMD ["nginx", "-g", "daemon off;"]
18 changes: 18 additions & 0 deletions nginx/api.conf
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to conf.d/

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {
listen 3000;
server_name api;
root /app/public;
index index.php;

location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass api:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
10 changes: 10 additions & 0 deletions nginx/conf.d/frontend.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 1212;
server_name matcha;
root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}
}