Skip to content

Commit

Permalink
Update 2.0 (#172)
Browse files Browse the repository at this point in the history
* feat Change directory structure (#151)

* fix Remove label (#154)

* feat Add --no-install-recommends option (#155)

* feat Change unix domain socket to tcp socket (#157)

* feat Remove Node from web container (#163)

* fix Remove unnecessary volumes (#165)

* feat Remove .env.example (#167)

* fix Makefile

* feat Change the base image OS of the web container from alpine to debian (#169)

* feat Remove shell instructions (#171)
  • Loading branch information
ucan-lab authored Mar 1, 2022
1 parent 3cd1925 commit 2082245
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 94 deletions.
5 changes: 0 additions & 5 deletions .env.example

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/laravel-create-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: Create & Start Docker Containers
run: |
mkdir backend
mkdir src
docker-compose up -d
- name: OS Version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/laravel-git-clone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2

- name: Git Clone Project
run: git clone https://github.com/laravel/laravel.git backend
run: git clone https://github.com/laravel/laravel.git src

- name: Docker Version
run: docker version
Expand Down
32 changes: 4 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build:
laravel-install:
docker compose exec app composer create-project --prefer-dist laravel/laravel .
create-project:
mkdir -p backend
mkdir -p src
@make build
@make up
@make laravel-install
Expand Down Expand Up @@ -37,13 +37,13 @@ stop:
docker compose stop
down:
docker compose down --remove-orphans
down-v:
docker compose down --remove-orphans --volumes
restart:
@make down
@make up
destroy:
docker compose down --rmi all --volumes --remove-orphans
destroy-volumes:
docker compose down --volumes --remove-orphans
ps:
docker compose ps
logs:
Expand All @@ -63,7 +63,7 @@ log-db:
log-db-watch:
docker compose logs --follow db
web:
docker compose exec web ash
docker compose exec web bash
app:
docker compose exec app bash
migrate:
Expand Down Expand Up @@ -94,30 +94,6 @@ cache-clear:
docker compose exec app composer clear-cache
@make optimize-clear
docker compose exec app php artisan event:clear
npm:
@make npm-install
npm-install:
docker compose exec web npm install
npm-dev:
docker compose exec web npm run dev
npm-watch:
docker compose exec web npm run watch
npm-watch-poll:
docker compose exec web npm run watch-poll
npm-hot:
docker compose exec web npm run hot
yarn:
docker compose exec web yarn
yarn-install:
@make yarn
yarn-dev:
docker compose exec web yarn dev
yarn-watch:
docker compose exec web yarn watch
yarn-watch-poll:
docker compose exec web yarn watch-poll
yarn-hot:
docker compose exec web yarn hot
db:
docker compose exec db bash
sql:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ http://localhost
### web container

- Base image
- [nginx](https://hub.docker.com/_/nginx):1.20-alpine
- [node](https://hub.docker.com/_/node):16-alpine
- [nginx](https://hub.docker.com/_/nginx):1.20

### db container

Expand Down
37 changes: 13 additions & 24 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: "3.9"
volumes:
php-fpm-socket:
db-store:
psysh-store:
services:
Expand All @@ -9,14 +8,9 @@ services:
context: .
dockerfile: ./infra/docker/php/Dockerfile
volumes:
- type: volume
source: php-fpm-socket
target: /var/run/php-fpm
volume:
nocopy: true
- type: bind
source: ./backend
target: /work/backend
source: ./src
target: /data
- type: volume
source: psysh-store
target: /root/.config/psysh
Expand All @@ -26,36 +20,31 @@ services:
- DB_CONNECTION=mysql
- DB_HOST=db
- DB_PORT=3306
- DB_DATABASE=${DB_NAME:-laravel_local}
- DB_USERNAME=${DB_USER:-phper}
- DB_PASSWORD=${DB_PASS:-secret}
- DB_DATABASE=laravel
- DB_USERNAME=phper
- DB_PASSWORD=secret

web:
build:
context: .
dockerfile: ./infra/docker/nginx/Dockerfile
ports:
- target: 80
published: ${WEB_PORT:-80}
published: 80
protocol: tcp
mode: host
volumes:
- type: volume
source: php-fpm-socket
target: /var/run/php-fpm
volume:
nocopy: true
- type: bind
source: ./backend
target: /work/backend
source: ./src
target: /data

db:
build:
context: .
dockerfile: ./infra/docker/mysql/Dockerfile
ports:
- target: 3306
published: ${DB_PORT:-3306}
published: 3306
protocol: tcp
mode: host
volumes:
Expand All @@ -65,7 +54,7 @@ services:
volume:
nocopy: true
environment:
- MYSQL_DATABASE=${DB_NAME:-laravel_local}
- MYSQL_USER=${DB_USER:-phper}
- MYSQL_PASSWORD=${DB_PASS:-secret}
- MYSQL_ROOT_PASSWORD=${DB_PASS:-secret}
- MYSQL_DATABASE=laravel
- MYSQL_USER=phper
- MYSQL_PASSWORD=secret
- MYSQL_ROOT_PASSWORD=secret
1 change: 0 additions & 1 deletion infra/docker/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM mysql/mysql-server:8.0
LABEL maintainer="ucan-lab <yes@u-can.pro>"

ENV TZ=UTC

Expand Down
19 changes: 3 additions & 16 deletions infra/docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
FROM node:16-alpine as node
FROM nginx:1.20-alpine
LABEL maintainer="ucan-lab <yes@u-can.pro>"
SHELL ["/bin/ash", "-oeux", "pipefail", "-c"]
FROM nginx:1.20

ENV TZ=UTC
WORKDIR /data

RUN apk update && \
apk add --update --no-cache --virtual=.build-dependencies g++
ENV TZ=UTC

# node command
COPY --from=node /usr/local/bin /usr/local/bin
# npm command
COPY --from=node /usr/local/lib /usr/local/lib
# yarn command
COPY --from=node /opt /opt
# nginx config file
COPY ./infra/docker/nginx/*.conf /etc/nginx/conf.d/

WORKDIR /work/backend
4 changes: 2 additions & 2 deletions infra/docker/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error_log /dev/stderr warn;
server {
listen 80;
listen [::]:80;
root /work/backend/public;
root /data/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
Expand All @@ -24,7 +24,7 @@ server {
error_page 404 /index.php;

location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_pass app:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
Expand Down
12 changes: 4 additions & 8 deletions infra/docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM php:8.1-fpm-bullseye
LABEL maintainer="ucan-lab <yes@u-can.pro>"
SHELL ["/bin/bash", "-oeux", "pipefail", "-c"]

WORKDIR /data

# timezone environment
ENV TZ=UTC \
Expand All @@ -15,17 +15,13 @@ ENV TZ=UTC \
COPY --from=composer:2.2 /usr/bin/composer /usr/bin/composer

RUN apt-get update && \
apt-get -y install git libicu-dev libonig-dev libzip-dev unzip locales && \
apt-get -y install --no-install-recommends locales git unzip libzip-dev libicu-dev libonig-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
locale-gen en_US.UTF-8 && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
mkdir /var/run/php-fpm && \
docker-php-ext-install intl pdo_mysql zip bcmath && \
composer config -g process-timeout 3600 && \
composer config -g repos.packagist composer https://packagist.org

COPY ./infra/docker/php/php-fpm.d/zzz-www.conf /usr/local/etc/php-fpm.d/zzz-www.conf
COPY ./infra/docker/php/php.ini /usr/local/etc/php/php.ini

WORKDIR /work/backend
COPY ./infra/docker/php/*.ini /usr/local/etc/php/
6 changes: 0 additions & 6 deletions infra/docker/php/php-fpm.d/zzz-www.conf

This file was deleted.

0 comments on commit 2082245

Please sign in to comment.