This commit is contained in:
jhx
2023-08-18 11:34:58 +08:00
commit 49ea1bb75d
16 changed files with 583 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
### set local app dir there #######
HOST_APP_DIR=../
CONTAINER_APP_DIR=/usr/src/myapp
HOST_PORT=8001
CONTAINER_PORT=8001
INSTALL_COMPOSER=true
COMPOSER_INSTALLER=https://install.phpcomposer.com/installer
COMPOSER_MIRROR=https://mirrors.aliyun.com/composer/
INSTALL_LIB_EVENT=true
CHANGE_AlPINE_SOURCE=true
CONTAINER_PACKAGE_URL=mirrors.aliyun.com
CONTAINER_NAME=workerman-rpc
+77
View File
@@ -0,0 +1,77 @@
FROM php:7.4-cli-alpine3.13
# Set working dir.
ARG CONTAINER_APP_DIR
ARG timezone
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \
APP_ENV=prod \
SCAN_CACHEABLE=(true)
# Change alpinelinux source.
# Reference: https://github.com/laradock/laradock
ARG CHANGE_AlPINE_SOURCE
ARG CONTAINER_PACKAGE_URL
RUN if [ $CHANGE_AlPINE_SOURCE ] ; then sed -i "s/dl-cdn.alpinelinux.org/${CONTAINER_PACKAGE_URL}/g" /etc/apk/repositories ; fi
RUN uname -a && \
apk update
RUN docker-php-ext-install sockets pcntl && \
docker-php-ext-install pdo_mysql
RUN apk add --no-cache pcre-dev $PHPIZE_DEPS && \
pecl install redis && \
docker-php-ext-enable redis
ARG INSTALL_LIB_EVENT
RUN if [ ${INSTALL_LIB_EVENT} = true ]; then \
apk add libevent-dev openssl-dev libressl-dev && \
pecl install event && \
echo extension=event.so > /usr/local/etc/php/conf.d/event.ini \
;fi
# update
RUN set -ex \
# show php version and extensions
&& php -v \
&& php -m \
# ---------- some config ----------
&& cd /usr/local/etc/php \
# - config PHP
&& { \
echo "upload_max_filesize=128M"; \
echo "post_max_size=128M"; \
echo "memory_limit=1G"; \
echo "date.timezone=${TIMEZONE}"; \
} | tee conf.d/99_overrides.ini \
# - config timezone
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone \
# ---------- clear works ----------
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
# Install composer and set mirror.
# Reference: https://pkg.phpcomposer.com/#how-to-install-composer
# Referencr: https://developer.aliyun.com/composer
ARG INSTALL_COMPOSER
ARG COMPOSER_INSTALLER
ARG COMPOSER_MIRROR
RUN if [ ${INSTALL_COMPOSER} = true ]; then \
php -r "copy('${COMPOSER_INSTALLER}', 'composer-setup.php');" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');" && \
mv composer.phar /usr/local/bin/composer && \
composer config -g repo.packagist composer ${COMPOSER_MIRROR} \
;fi
RUN apk add git zip vim bash
# Expose port
ARG CONTAINER_PORT
EXPOSE ${CONTAINER_PORT}
WORKDIR ${CONTAINER_APP_DIR}
+24
View File
@@ -0,0 +1,24 @@
# Set environment variables
Copy file **env-example** to **.env**, and change the item what you need.
Change the **HOST_APP_DIR** env item, ensure where your webman app is.
# Build image
Ensure you have install docker and docker-compose first.
You can build you image by execute follow command:
> **docker-compose up -d webman**
# Run
Enter the container:
> **docker-compose exec webman bash**
If you havn't init composer, you can run this command:
> **composer install**
Run in front:
> **php start.php start**
Run in backend:
> **php start.php start -d**
+28
View File
@@ -0,0 +1,28 @@
version: '3'
services:
workerman-rpc:
build:
context: ./
args:
- CONTAINER_PORT=${CONTAINER_PORT}
- CONTAINER_APP_DIR=${CONTAINER_APP_DIR}
- INSTALL_COMPOSER=${INSTALL_COMPOSER}
- COMPOSER_INSTALLER=${COMPOSER_INSTALLER}
- COMPOSER_MIRROR=${COMPOSER_MIRROR}
- INSTALL_LIB_EVENT=${INSTALL_LIB_EVENT}
- CONTAINER_PACKAGE_URL=${CONTAINER_PACKAGE_URL}
- CHANGE_AlPINE_SOURCE=${CHANGE_AlPINE_SOURCE}
ports:
- "9501:9501"
volumes:
- ${HOST_APP_DIR}:${CONTAINER_APP_DIR}
container_name: ${CONTAINER_NAME}
networks:
- network
stdin_open: true
tty: true
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
network:
+11
View File
@@ -0,0 +1,11 @@
### set local app dir there #######
HOST_APP_DIR=../webman
CONTAINER_APP_DIR=/usr/src/myapp
HOST_PORT=8787
CONTAINER_PORT=8787
INSTALL_COMPOSER=true
COMPOSER_INSTALLER=https://install.phpcomposer.com/installer
COMPOSER_MIRROR=https://mirrors.aliyun.com/composer/
INSTALL_LIB_EVENT=true
CHANGE_UBUNTU_SOURCE=true
UBUNTU_SOURCE=tsinghua
Binary file not shown.
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# Reference: https://github.com/laradock/laradock
set -xe;
if type "tee" 2>/dev/null && [ -n "${UBUNTU_SOURCE}" ]; then
SOURCE_PATH="/etc/apt/sources.list"
cp ${SOURCE_PATH} ${SOURCE_PATH}.bak && rm -rf ${SOURCE_PATH}
case "${UBUNTU_SOURCE}" in
"aliyun")
tee ${SOURCE_PATH} <<-'EOF'
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
EOF
;;
"tsinghua")
tee ${SOURCE_PATH} <<-'EOF'
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
EOF
;;
*)
echo "There is no ubuntu source detected!"
exit 1;;
esac
fi