一些常用DockerFile和docker-compose.yml文件
go-zero中的配置用在gin框架中
Dockerfile
FROM golang:alpine AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update --no-cache && apk add --no-cache tzdata
WORKDIR /build
ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
COPY env.ini /app/env.ini
RUN go build -ldflags="-s -w" -o /app/[项目名称] main.go
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai
WORKDIR /app
COPY --from=builder /app/[项目名称] /app/[项目名称]
COPY --from=builder /app/env.ini /app/env.ini
CMD ["./[项目名称]"]
docker-compose.yml
version: '2'
services:
web:
image: [项目名称]:latest
volumes:
- ./logs:/app/logs
ports:
- "0.0.0.0:8080:8080"
nginx常用docker-compose.yml
version: "2"
services:
rabbitmq:
image: nginx:latest
container_name: 'nginx'
ports:
- 80:80
volumes:
- ./html:/usr/share/nginx/html
mysql常用docker-compose.yml
version: '3.1'
services:
db:
image: mysql
restart: always
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: 123456
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
ports:
- 3306:3306
volumes:
- ./data:/var/lib/mysql
- ./conf:/etc/mysql/conf.d
- ./logs:/logs
rabbitmq常用docker-compose.yml
version: "3.7"
services:
rabbitmq:
image: rabbitmq:3.11-management-alpine
container_name: 'rabbitmq'
ports:
- 5672:5672
- 15672:15672
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
- rabbitmq_log:/var/log/rabbitmq/
volumes:
rabbitmq_data:
rabbitmq_log:
redis常用docker-compose.yml
需要先写redis.conf文件, 不然会生成redis.conf目录
vi redis.conf
version: '3.1'
services:
redis:
image: redis:7.0.10
container_name: 'redis'
ports:
- 6379:6379
volumes:
- ./redis.conf:/etc/redis/redis.conf
command:
redis-server /etc/redis/redis.conf
restart: always
php项目sendmail配置
项目基于laravel框架搭建
包含redis扩展和composer安装
Dockerfile
FROM php:8.1.18-cli
RUN pecl install redis-5.3.7 \
&& docker-php-ext-enable redis
COPY . /myapp
WORKDIR /mycomposer
RUN apt-get update && apt-get install -y zip
ENV COMPOSER_HOME /root/composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
ENV PATH $COMPOSER_HOME/vendor/bin:$PATH
WORKDIR /myapp
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
&& COMPOSER_ALLOW_SUPERUSER=1 composer install
CMD [ "php", "/myapp/artisan", "serve", "--host=0.0.0.0", "--port=80"]
docker-compose.myl
version: '2'
services:
web:
image: sendmail:1.1
volumes:
- ./storage/logs:/myapp/storage/logs
- ./.env:/myapp/.env
ports:
- "0.0.0.0:80:80"
restart: unless-stopped
alist网盘配置
docker-compose.myl
version: '3.3'
services:
alist:
restart: always
volumes:
- ./data:/opt/alist/data
- ./test:/test
ports:
- '5244:5244'
environment:
- PUID=0
- PGID=0
- UMASK=022
container_name: alist
image: 'xhofe/alist:latest'
gitea自建代码仓库配置
docker-compose.myl
version: "3"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:1.19.0-rc1
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=mysql
- GITEA__database__HOST=db:3306
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
restart: always
networks:
- gitea
volumes:
- /home/git/.ssh/:/data/git/.ssh
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "22:22"
depends_on:
- db
db:
image: mysql:8
restart: always
environment:
- MYSQL_ROOT_PASSWORD=gitea
- MYSQL_USER=gitea
- MYSQL_PASSWORD=gitea
- MYSQL_DATABASE=gitea
networks:
- gitea
volumes:
- ./mysql:/var/lib/mysql
chatgpt-next-web网页GPT配置
docker-compose.myl
version: '3.3'
services:
chat:
restart: always
ports:
- '3000:3000'
environment:
- OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXXXXXXX
- CODE=mimamimamimamima
container_name: chat
image: 'yidadaa/chatgpt-next-web:latest'
微信自动回复GPT配置,扫码登录
docker-compose.myl
version: '2.0'
services:
wechat:
image: zhayujie/chatgpt-on-wechat
environment:
OPEN_AI_API_BASE: 'https://openai.com/v1'
OPEN_AI_API_KEY: 'sk-XXXXXXXXXXXXXXXXXXXXX'
OPEN_AI_PROXY: ''
SINGLE_CHAT_PREFIX: '[""]'
SINGLE_CHAT_REPLY_PREFIX: ''
GROUP_CHAT_PREFIX: '["@bot"]'
GROUP_NAME_WHITE_LIST: '["ChatGPT测试群", "ChatGPT测试群2"]'
IMAGE_CREATE_PREFIX: '["画", "看", "找"]'
CONVERSATION_MAX_TOKENS: 2000
SPEECH_RECOGNITION: "True"
CHARACTER_DESC: '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'
EXPIRES_IN_SECONDS: 3600
restart: unless-stopped
远程桌面rustdesk远程控制
docker-compose.myl
version: '3'
networks:
rustdesk-net:
external: false
services:
hbbs:
container_name: hbbs
ports:
- 21115:21115
- 21116:21116
- 21116:21116/udp
image: rustdesk/rustdesk-server:latest
command: hbbs -r <你的域名>:21117
volumes:
- ./data:/root
networks:
- rustdesk-net
depends_on:
- hbbr
restart: unless-stopped
hbbr:
container_name: hbbr
ports:
- 21117:21117
image: rustdesk/rustdesk-server:latest
command: hbbr
volumes:
- ./data:/root
networks:
- rustdesk-net
restart: unless-stopped