Skip to content
Open
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ APP_NAME="純靠北工程師"
APP_ENV="local" #"local"、"production"
APP_KEY=
APP_URL="https://init.engineer"
APP_PORT="80"


# |--------------------------------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM php:8.1.4-fpm

RUN apt-get update && apt-get install -y libmcrypt-dev \
mariadb-client libmagickwand-dev libpng-dev \
libonig-dev libzip-dev zip libpng-dev libjpeg-dev \
libfreetype6-dev --no-install-recommends \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install zip pdo_mysql mbstring gd \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["docker-php-entrypoint"]

WORKDIR /var/www/html

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

EXPOSE 8000

CMD ["php-fpm"]
48 changes: 48 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: '3.8'
services:

nginx:
image: nginx:stable-alpine
restart: always
links:
- app
ports:
- "${APP_PORT}:80"
depends_on:
- app
volumes:
- ./docker/conf/nginx_default.conf:/etc/nginx/conf.d/default.conf
- ./storage/app/public:/usr/share/nginx/html/storage

app:
build:
context: ./
dockerfile: Dockerfile
volumes:
- ./:/var/www/html
command: bash -c "php artisan serve --host=0.0.0.0 --port=8000"

mysql:
image: mysql:5.7
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql

redis:
image: redis
ports:
- "6379:6379"
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD}
volumes:
- redis_data:/data

volumes:
mysql_data:
redis_data:
17 changes: 17 additions & 0 deletions docker/conf/nginx_default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
listen 80;
server_name _;

location /storage/cards/images/ {
autoindex on;
root /usr/share/nginx/html;
}

location / {
proxy_pass http://app:8000;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
}
}
14 changes: 14 additions & 0 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# 此腳本用於初次架設需進行的 Laravel 專案設定
# 請先確保已透過 docker-compose up -d 建立好所有的 docker container

echo ""
echo "key generate"
echo ""
docker-compose exec app php artisan key:generate

echo ""
echo "migrate"
echo ""
docker-compose exec app php artisan migrate
13 changes: 13 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# 透過 image composer 進行 composer install
echo ""
echo "Setup composer and install dependencies"
echo ""
docker run --rm -v `pwd`:/app --workdir /app composer composer install

# 透過 image node 進行 npm install
echo ""
echo "Setup npm and install dependencies"
echo ""
docker run --rm -v `pwd`:/app --workdir /app node:lts npm install && npm run prod