Skip to content

Commit

Permalink
docker
Browse files Browse the repository at this point in the history
  • Loading branch information
wouerner committed Mar 22, 2024
1 parent e54eee6 commit 20bb33f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ vendor/
.DS_Store
.phpunit*
*.cache
.vscode/
.vscode/
26 changes: 15 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Default Dockerfile
#
# @link https://www.hyperf.io
# @document https://hyperf.wiki
# @contact group@hyperf.io
# @license https://github.com/hyperf/hyperf/blob/master/LICENSE
FROM composer:2.7 as vendor

COPY . /app

COPY composer.json composer.json
COPY composer.lock composer.lock

RUN composer install \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-scripts \
--prefer-dist

FROM hyperf/hyperf:8.1-alpine-v3.18-swoole
LABEL maintainer="Hyperf Developers <group@hyperf.io>" version="1.0" license="MIT" app.name="Hyperf"
Expand Down Expand Up @@ -42,12 +49,9 @@ RUN set -ex \

WORKDIR /opt/www

# Composer Cache
# COPY ./composer.* /opt/www/
# RUN composer install --no-dev --no-scripts

COPY . /opt/www
RUN composer install --no-dev -o && php bin/hyperf.php

COPY --from=vendor /app/vendor/ /opt/www/vendor/

EXPOSE 9501

Expand Down
19 changes: 14 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
version: '3'
services:
hyperf-skeleton:
container_name: hyperf-skeleton
image: hyperf-skeleton
container_name: labs-api
image: labs-api
build:
context: .
volumes:
- ./:/opt/www
- /opt/www/vendor
ports:
- 9501:9501
- 9500:9500
environment:
- APP_ENV=dev
- SCAN_CACHEABLE=false
entrypoint: ["php", "/opt/www/bin/hyperf.php", "server:watch"]
# entrypoint: ["php", "/opt/www/bin/hyperf.php", "server:watch"]
entrypoint: ["/opt/www/docker/entrypoint.sh"]
depends_on:
db-labs:
condition: service_healthy

db:
container_name: mysql8
db-labs:
container_name: db-labs
image: mysql:8.3
command: mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
Expand All @@ -28,6 +33,10 @@ services:
- './docker/db/data:/var/lib/mysql'
- './docker/db/my.cnf:/etc/mysql/conf.d/my.cnf'
- './docker/db/sql:/docker-entrypoint-initdb.d'
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10

networks:
default:
Expand Down
7 changes: 7 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

echo "Migrate"
php /opt/www/bin/hyperf.php migrate

echo "Starting my application..."
php /opt/www/bin/hyperf.php start

0 comments on commit 20bb33f

Please sign in to comment.