File tree 7 files changed +66
-39
lines changed
7 files changed +66
-39
lines changed Original file line number Diff line number Diff line change 1
- FROM golang:1.22-alpine3.20 as builder
1
+ FROM golang:1.22-alpine3.20 AS builder
2
+
3
+ RUN apk add --no-cache upx
2
4
3
5
WORKDIR /app
4
6
7
+ COPY go.mod go.sum ./
8
+ RUN go mod download
9
+
5
10
COPY . .
6
11
7
- RUN go get -d -v ./...
12
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags= "-s -w" -o /app/api ./cmd/api/main.go
8
13
9
- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o api ./cmd /api/main.go
14
+ RUN upx --ultra-brute -qq /app/api && upx -t /app /api
10
15
11
16
FROM scratch
12
17
13
- WORKDIR /
18
+ COPY --from=builder /app/api /api
14
19
15
- COPY --from=builder /app/ api ./
20
+ ENTRYPOINT [ "/ api" ]
16
21
17
- ENTRYPOINT ["./api" ]
Original file line number Diff line number Diff line change 1
- FROM postgres:13.14-alpine
2
-
3
- COPY ./build/db/init.sh /docker-entrypoint-initdb.d/
4
-
5
- RUN chmod +x /docker-entrypoint-initdb.d/init.sh
1
+ FROM postgres:13.14-alpine
Load Diff This file was deleted.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ listen_addresses = '*'
2
+ max_connections = 300
3
+ superuser_reserved_connections = 3
4
+ unix_socket_directories = '/var/run/postgresql'
5
+ shared_buffers = 512MB
6
+ work_mem = 8MB
7
+ maintenance_work_mem = 256MB
8
+ effective_cache_size = 1GB
9
+ wal_buffers = 64MB
10
+ synchronous_commit = on
11
+ fsync = on
12
+ full_page_writes = on
13
+ checkpoint_timeout = 10min
14
+ checkpoint_completion_target = 0.9
15
+ random_page_cost = 4.0
16
+ effective_io_concurrency = 2
17
+ autovacuum = on
18
+ log_statement = 'mod'
19
+ log_duration = off
20
+ log_lock_waits = on
21
+ log_error_verbosity = terse
22
+ log_min_messages = error
23
+ log_min_error_statement = error
24
+ log_min_duration_statement = 1000ms
Original file line number Diff line number Diff line change
1
+ save ""
2
+
3
+ appendonly no
4
+ appendfsync no
5
+ stop-writes-on-bgsave-error no
6
+ rdbcompression no
7
+ rdbchecksum no
8
+ rdb-save-incremental-fsync no
9
+ aof-rewrite-incremental-fsync no
10
+ bind 0.0.0.0
11
+ maxmemory-samples 2
12
+ activerehashing no
13
+ dynamic-hz yes
14
+ tcp-keepalive 300
15
+ always-show-logo yes
16
+ rdb-save-incremental-fsync no
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ services:
14
14
dockerfile : build/db/Dockerfile
15
15
volumes :
16
16
- local_postgres_data:/var/lib/postgresql/data
17
+ - ./conf/postgres/:/docker-entrypoint-initdb.d/
17
18
ports :
18
19
- " 5432:5432"
19
20
networks :
@@ -24,11 +25,16 @@ services:
24
25
timeout : 5s
25
26
retries : 3
26
27
start_period : 20s
28
+ command :
29
+ [
30
+ " postgres" ,
31
+ " -c" ,"config_file=/docker-entrypoint-initdb.d/postgresql.conf",
32
+ ]
27
33
deploy :
28
34
resources :
29
35
limits :
30
- cpus : ' 0.4 '
31
- memory : ' 0.4GB '
36
+ cpus : ' 1.0 '
37
+ memory : ' 1GB '
32
38
33
39
migrate :
34
40
image : migrate/migrate
@@ -50,19 +56,21 @@ services:
50
56
cache :
51
57
container_name : rd02
52
58
image : redis:latest
53
- command : redis-server --save "" --appendonly no
54
59
environment :
55
60
REDIS_HOST : cache
56
61
REDIS_PORT : 6379
57
62
REDIS_PASSWORD : " "
58
63
ports :
59
64
- " 6379:6379"
65
+ volumes :
66
+ - ./conf/redis/:/etc/redis/
67
+ command : ["redis-server", "/etc/redis/redis.conf"]
60
68
networks :
61
69
- golangnetwork
62
70
deploy :
63
71
resources :
64
72
limits :
65
- cpus : ' 0.1 '
73
+ cpus : ' 0.3 '
66
74
memory : ' 0.5GB'
67
75
68
76
api :
@@ -88,16 +96,16 @@ services:
88
96
deploy :
89
97
resources :
90
98
limits :
91
- cpus : ' 0.1 '
92
- memory : ' 0.1GB '
99
+ cpus : ' 0.3 '
100
+ memory : ' 0.15GB '
93
101
94
102
nginx :
95
103
image : nginx:latest
96
104
container_name : nx02
97
105
ports :
98
106
- " 80:80"
99
107
volumes :
100
- - ./nginx. conf:/etc/nginx/nginx.conf:ro
108
+ - ./conf/nginx/ :/etc/nginx/
101
109
depends_on :
102
110
- api
103
111
networks :
You can’t perform that action at this time.
0 commit comments