Dockerfile
FROM hyperf/hyperf:7.4-alpine-v3.15-swoole
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#定义变量 ARG TZ=Asia/Shanghai
#变量使用&& echo "$TZ" > /etc/timezone
# && set -ex \ && apk del tzdata
# sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
# sed -i "s/dl-cdn.alpinelinux.org/mirrors.tencent.com/g" /etc/apk/repositories \
#
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.tencent.com/g" /etc/apk/repositories \
&& apk update \
#&& apk upgrade \
&& apk --no-cache add tzdata \
&& cp "/usr/share/zoneinfo/Asia/Shanghai" /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& set -ex \
&& apk add php7-mongodb \
&& apk add php7-amqp
# 安装php7-redis
RUN apk add php7-redis
#安装dbase命令
RUN apk add $PHPIZE_DEPS && \
CPPFLAGS="-DHAVE_SYS_FILE_H" pecl install dbase && \
echo "extension=dbase" >/etc/php7/conf.d/11_dbase.ini && \
apk del $PHPIZE_DEPS
# 安装composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
打包命令
- 正常打包里报ERROR,添加 —network=host(换不同的源,可以build成功)
docker build -t hyperf:7.4-alpine-v3.15-swoole-dbase . --network=host
docker-compose.yaml
version: "3.9"
services:
hyper7:
image: hyperf/hyperf:7.4-alpine-v3.15-swoole
#build: .
restart: always
#network_mode: host
container_name: $
deploy:
#mode: replicated
#replicas: 1
#endpoint_mode: dnsrr
#placement:
# constraints: [node.role == worker ]
resources:
limits:
cpus: "$"
memory: "$"
volumes:
#- "/data/code/hyperfDemo:/home/demo"
- "$/www:/opt/www"
ports:
- "$:$"
- "$:$"
tty: true
#privileged: true
working_dir: /opt/www
entrypoint: ["/opt/Entrypoint.sh"]
environment:
- TZ=Asia/Shanghai
networks:
- default_net
networks:
default_net:
name: $
driver: bridge
external: true
deploy.yml
version: "3.9"
services:
hyperf7:
image: $
deploy:
mode: replicated
replicas: 1
#endpoint_mode: dnsrr
#placement:
# constraints: [node.role == worker ]
resources:
limits:
cpus: "$"
memory: "$"
restart_policy:
condition: any
delay: 3s
#max_attempts: 6
#window: 60s
volumes:
- "$/www:/opt/www"
ports:
- "$:$"
- "$:$"
working_dir: /opt/www
entrypoint: ["/opt/Entrypoint.sh"]
environment:
- TZ=$
networks:
- default_net
networks:
default_net:
name: $
external: true