-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
194cf39
commit e25e464
Showing
9 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,6 @@ | |
# 苹果系统的文件 | ||
.DS_Store | ||
|
||
logs | ||
logs | ||
harukaze.top.crt | ||
harukaze.top.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 使用一个基础的 Golang 镜像 | ||
FROM golang:alpine as build | ||
|
||
# 为我们的镜像设置必要的环境变量 | ||
ENV GO111MODULE=on \ | ||
CGO_ENABLED=0 \ | ||
GOOS=linux \ | ||
GOARCH=arm64 \ | ||
GOPROXY=https://goproxy.cn | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 复制 Golang 项目的源代码到容器中 | ||
COPY . /app | ||
|
||
# 在容器中编译 Golang 项目 | ||
RUN go build -o blog cmd/main.go | ||
|
||
# 创建最终的生产镜像 | ||
FROM alpine:latest as prod | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 从之前的阶段复制二进制文件 | ||
COPY --from=build /app/blog /app/ | ||
COPY --from=build /app/internal/conf/* /app/internal/conf/ | ||
|
||
# 设置环境变量等 | ||
ENV PORT=18080 | ||
|
||
# 暴露端口 | ||
EXPOSE 18080 | ||
|
||
# 启动应用 | ||
CMD ["./blog"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
version: "3" | ||
|
||
services: | ||
backend: | ||
image: blog-backend-image | ||
volumes: | ||
- ./internal/conf:/app/internal/conf | ||
depends_on: | ||
- blog-postgres | ||
- blog-redis | ||
restart: always | ||
networks: | ||
- go-blog-net | ||
frontend: | ||
image: blog-frontend-image | ||
volumes: | ||
- ./nginx:/etc/nginx/conf.d | ||
- ./internal/conf:/app/conf | ||
restart: always | ||
ports: | ||
- 443:443 | ||
networks: | ||
- go-blog-net | ||
blog-postgres: | ||
image: postgres:latest | ||
volumes: | ||
- ./pg/data:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_PASSWORD: 1234567 | ||
POSTGRES_USER: go-blog | ||
POSTGRES_DB: blog | ||
networks: | ||
- go-blog-net | ||
blog-redis: | ||
image: redis:latest | ||
networks: | ||
- go-blog-net | ||
networks: | ||
go-blog-net: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
server { | ||
charset utf-8; | ||
client_max_body_size 128M; | ||
|
||
listen 443 ssl; | ||
server_name harukaze.top; | ||
|
||
ssl_certificate /app/conf/harukaze.top.crt; # 证书文件的路径 | ||
ssl_certificate_key /app/conf/harukaze.top.key; # 证书私钥文件的路径 | ||
|
||
root /usr/share/nginx/html; | ||
index index.html; | ||
|
||
# access_log /data/logs/nginx/project.dev.com-access.log; | ||
# error_log /data/logs/nginx/project.dev.com-error.log debug; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
location /api/ { | ||
proxy_pass https://backend:18080/; | ||
} | ||
|
||
location ^~ /backend { | ||
alias /data/www/wwwroot/project/backend/public/; | ||
if (!-e $request_filename) { | ||
rewrite ^ /backend/index.php last; | ||
} | ||
index index.php; | ||
location ~ \.php$ { | ||
include fastcgi_params; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $request_filename; | ||
fastcgi_pass 127.0.0.1:9000; | ||
} | ||
} | ||
|
||
#location @backend { | ||
# rewrite /backend/(.*)$ /backend/index.php/$1 last; | ||
#} | ||
location ~* /\. { | ||
deny all; | ||
} | ||
} |