添加 Dockerfile 以及测试环境脚本;docker 脚本复用环境变量
This commit is contained in:
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM ubuntu:20.04
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./bin/platform_linux_amd64 /app/platform
|
||||||
|
RUN chmod +x /app/platform
|
||||||
|
|
||||||
|
EXPOSE $APP_PORT
|
||||||
|
|
||||||
|
CMD ["/app/proxy"]
|
||||||
4
pkg/env/env.go
vendored
4
pkg/env/env.go
vendored
@@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
AppName = "platform"
|
AppName = "platform"
|
||||||
AppPort = "8080"
|
AppPort string
|
||||||
)
|
)
|
||||||
|
|
||||||
func loadApp() {
|
func loadApp() {
|
||||||
@@ -25,6 +25,8 @@ func loadApp() {
|
|||||||
_AppPort := os.Getenv("APP_PORT")
|
_AppPort := os.Getenv("APP_PORT")
|
||||||
if _AppPort != "" {
|
if _AppPort != "" {
|
||||||
AppPort = _AppPort
|
AppPort = _AppPort
|
||||||
|
} else {
|
||||||
|
panic("环境变量 APP_PORT 的值不能为空")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: server-dev
|
name: platform-dev
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
@@ -6,13 +6,14 @@ services:
|
|||||||
image: postgres:17
|
image: postgres:17
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: test
|
POSTGRES_USER: ${DB_USERNAME}
|
||||||
POSTGRES_PASSWORD: test
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
POSTGRES_DB: app
|
POSTGRES_DB: ${DB_NAME}
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7.4
|
image: redis:7.4
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
39
scripts/prev/docker-compose.yaml
Normal file
39
scripts/prev/docker-compose.yaml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: platform-prev
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:17
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${DB_USERNAME}
|
||||||
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
|
POSTGRES_DB: ${DB_NAME}
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7.4
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
|
||||||
|
platform:
|
||||||
|
build:
|
||||||
|
context: ../..
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
- redis
|
||||||
|
ports:
|
||||||
|
- ${APP_PORT}
|
||||||
|
env_file:
|
||||||
|
- ../../.env
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
|
redis_data:
|
||||||
Reference in New Issue
Block a user