Skip to content

Commit 4578d64

Browse files
authored
Docs: Fixed Deployment Scripts (frain-dev#1411)
* docs: added local docker files * docs: added local config * fix: fixed on-prem linux script * [skip ci] fix: on-prem script * [skip ci] fix: fixed docker compose
1 parent 5b3369f commit 4578d64

9 files changed

+133
-130
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
**/node_modules
22
node_modules
33
docker-compose.yml
4+
5+
# Convoy Specific
6+
typesense_data
7+
postgres_data
8+
redis_data

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ convoy
3333
convoy.json
3434
docker-compose.yml
3535
compose.yml
36-
typesense-data
36+
typesense_data
37+
postgres_data
38+
redis_data
3739
/.run/go test github.com_frain-dev_convoy_server.run.xml

Dockerfile Dockerfile.dev

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ COPY ./go.mod /go/src/frain-dev/convoy
1313
COPY ./go.sum /go/src/frain-dev/convoy
1414

1515
COPY --from=node-env /app/dist /go/src/frain-dev/convoy/server/ui/build
16+
1617
# Get dependancies - will also be cached if we don't change mod/sum
1718
RUN go mod download
1819
RUN go mod verify
@@ -23,11 +24,12 @@ COPY . .
2324
RUN CGO_ENABLED=0
2425
RUN go install ./cmd
2526

26-
FROM gcr.io/distroless/base
27+
FROM alpine:3.16.2
2728
COPY --from=build-env /go/bin/cmd /
2829
COPY --from=build-env /go/src/frain-dev/convoy/internal/email/templates/* templates/
30+
COPY --from=build-env /go/src/frain-dev/convoy/configs/local/start.sh /
2931

30-
ENTRYPOINT ["/cmd"]
31-
CMD [ "server", "--config", "convoy.json" ]
32+
RUN chmod +x /cmd
33+
RUN apk add --no-cache gcompat
3234

3335
EXPOSE 8080

configs/convoy.templ.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
2-
"environment": "dev",
32
"database": {
4-
"type": "mongodb",
5-
"dsn": "mongodb://mongo1:27017,mongo2:27017,mongo3:27017/convoy?replicaSet=myReplicaSet&readPreference=primary&ssl=false"
3+
"type": "postgres",
4+
"dsn": "postgres://convoy:convoy@postgres/convoy?sslmode=disabled"
65
},
76
"queue": {
87
"type": "redis",

configs/docker-compose.templ.yml

+18-72
Original file line numberDiff line numberDiff line change
@@ -3,109 +3,55 @@ version: "3"
33
services:
44
web:
55
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:$VERSION
6-
entrypoint: [ "/bin/sh" ]
7-
command: /compose/start
6+
command: [ "/start.sh" ]
87
hostname: web
98
container_name: web
109
volumes:
1110
- ./convoy.json:/convoy.json
12-
- ./compose:/compose
1311
restart: on-failure
1412
depends_on:
15-
- mongo1
16-
- mongo2
17-
- mongo3
13+
- postgres
1814
- redis_server
1915
- typesense
2016
networks:
2117
- backendCluster
2218

2319
scheduler:
2420
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:$VERSION
25-
entrypoint: ["./cmd", "scheduler", "--config", "convoy.json"]
21+
command: ["./cmd", "scheduler", "--config", "convoy.json"]
2622
volumes:
2723
- ./convoy.json:/convoy.json
2824
restart: on-failure
2925
depends_on:
30-
- mongo1
26+
- postgres
3127
- redis_server
3228
networks:
3329
- backendCluster
3430

3531
worker:
3632
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:$VERSION
37-
entrypoint: ["./cmd", "worker", "--config", "convoy.json"]
33+
command: ["./cmd", "worker", "--config", "convoy.json"]
3834
volumes:
3935
- ./convoy.json:/convoy.json
4036
restart: on-failure
4137
depends_on:
42-
- mongo1
38+
- postgres
4339
- redis_server
4440
networks:
4541
- backendCluster
4642

47-
mongo1:
48-
image: mongo:latest
49-
hostname: mongo1
50-
container_name: mongo1
51-
restart: always
52-
entrypoint:
53-
[
54-
"/usr/bin/mongod",
55-
"--bind_ip",
56-
"localhost,mongo1",
57-
"--replSet",
58-
"myReplicaSet",
59-
"--journal",
60-
"--dbpath",
61-
"/data/db",
62-
]
63-
volumes:
64-
- ./mongo1-data:/data/db
65-
networks:
66-
- backendCluster
67-
68-
mongo2:
69-
image: mongo:latest
70-
hostname: mongo2
71-
container_name: mongo2
72-
restart: always
73-
entrypoint:
74-
[
75-
"/usr/bin/mongod",
76-
"--bind_ip",
77-
"localhost,mongo2",
78-
"--replSet",
79-
"myReplicaSet",
80-
"--journal",
81-
"--dbpath",
82-
"/data/db",
83-
]
84-
volumes:
85-
- ./mongo2-data:/data/db
86-
networks:
87-
- backendCluster
88-
89-
mongo3:
90-
image: mongo:latest
91-
hostname: mongo3
92-
container_name: mongo3
93-
restart: always
94-
entrypoint:
95-
[
96-
"/usr/bin/mongod",
97-
"--bind_ip",
98-
"localhost,mongo3",
99-
"--replSet",
100-
"myReplicaSet",
101-
"--journal",
102-
"--dbpath",
103-
"/data/db",
104-
]
105-
volumes:
106-
- ./mongo3-data:/data/db
107-
networks:
108-
- backendCluster
43+
postgres:
44+
image: postgres:15.2-alpine
45+
restart: unless-stopped
46+
environment:
47+
POSTGRES_DB: convoy
48+
POSTGRES_USER: convoy
49+
POSTGRES_PASSWORD: convoy
50+
PGDATA: /data/postgres
51+
volumes:
52+
- ./postgres_data:/data/postgres
53+
networks:
54+
- backendCluster
10955

11056
redis_server:
11157
image: redis:alpine

configs/local/convoy.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
2-
"environment": "dev",
32
"database": {
4-
"type": "mongodb",
5-
"dsn": "mongodb://mongo:27017/convoy?replicaSet=localhost"
3+
"type": "postgres",
4+
"dsn": "postgres://convoy:convoy@postgres/convoy?sslmode=disable"
65
},
76
"queue": {
87
"type": "redis",

configs/local/docker-compose.yml

+24-24
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,56 @@ version: "3"
22

33
services:
44
web:
5-
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:v0.8.2
5+
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:v0.9.0-rc.1
6+
command: ["/start.sh"]
67
volumes:
78
- ./convoy.json:/convoy.json
89
restart: on-failure
910
ports:
1011
- "5005:5005"
1112
depends_on:
12-
- mongo
13+
- postgres
1314
- redis_server
1415
- typesense
1516

1617
scheduler:
17-
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:v0.8.2
18-
entrypoint: ["./cmd", "scheduler", "--config", "convoy.json"]
18+
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:v0.9.0-rc.1
19+
command: ["./cmd", "scheduler", "--config", "convoy.json"]
1920
volumes:
2021
- ./convoy.json:/convoy.json
2122
restart: on-failure
2223
depends_on:
23-
- mongo
24+
- postgres
2425
- redis_server
26+
- typesense
2527

2628
worker:
27-
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:v0.8.2
28-
entrypoint: ["./cmd", "worker", "--config", "convoy.json"]
29+
image: docker.cloudsmith.io/convoy/convoy/frain-dev/convoy:v0.9.0-rc.1
30+
command: ["./cmd", "worker", "--config", "convoy.json"]
2931
volumes:
3032
- ./convoy.json:/convoy.json
3133
restart: on-failure
3234
depends_on:
33-
- mongo
35+
- postgres
3436
- redis_server
37+
- typesense
3538

36-
mongo:
37-
image: mongo:5.0.14
38-
command: "--replSet localhost"
39-
restart: always
40-
ports:
41-
- "27017:27017"
42-
- "27018:27018"
43-
- "27019:27019"
44-
45-
mongosetup:
46-
image: mongo:5.0.14
47-
depends_on:
48-
- mongo
49-
restart: "no"
50-
entrypoint: [ "bash", "-c", "sleep 10 && mongo --host mongo:27017 --eval 'rs.initiate()'"]
39+
postgres:
40+
image: postgres:15.2-alpine
41+
restart: unless-stopped
42+
environment:
43+
POSTGRES_DB: convoy
44+
POSTGRES_USER: convoy
45+
POSTGRES_PASSWORD: convoy
46+
PGDATA: /data/postgres
47+
volumes:
48+
- ./postgres_data:/data/postgres
5149

5250
redis_server:
5351
image: redis:alpine
5452
restart: always
53+
volumes:
54+
- ./redis_data:/data
5555

5656
typesense:
5757
image: typesense/typesense:0.22.2
@@ -61,5 +61,5 @@ services:
6161
TYPESENSE_ENABLE_CORS: "true"
6262
TYPESENSE_API_KEY: "convoy"
6363
volumes:
64-
- ./typesense-data:/data/typesense
64+
- ./typesense_data:/data/typesense
6565

deploy/vm-deploy.sh

-24
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,6 @@ EOF
136136
# rewrite docker compose
137137
envsubst < docker-compose.templ.yml > docker-compose.yml
138138
rm docker-compose.templ.yml
139-
140-
# Fix compose start command
141-
cat > $COMPOSECONFDIR/start <<EOF
142-
#!/bin/bash
143-
./cmd migrate up
144-
./cmd server --config convoy.json -w false
145-
EOF
146-
chmod +x $COMPOSECONFDIR/start
147-
}
148-
149-
# setup replica set on mongo db clusters
150-
setup_replica_set() {
151-
echo
152-
docker exec mongo1 mongosh --eval "rs.initiate({
153-
_id: \"myReplicaSet\",
154-
members: [
155-
{_id: 0, host: \"mongo1\"},
156-
{_id: 1, host: \"mongo2\"},
157-
{_id: 2, host: \"mongo3\"}
158-
]
159-
})"
160139
}
161140

162141
# start system
@@ -221,9 +200,6 @@ start() {
221200
# start containers
222201
start_containers
223202

224-
# setup replica set
225-
setup_replica_set
226-
227203
# check if services are up
228204
check_if_containers_are_up
229205
}

docker-compose.dev.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
version: "3"
2+
3+
volumes:
4+
postgres_data:
5+
redis_data:
6+
typesense_data:
7+
8+
services:
9+
web:
10+
build:
11+
context: ./
12+
dockerfile: Dockerfile.dev
13+
command: [ "/start.sh" ]
14+
volumes:
15+
- ./convoy.json:/convoy.json
16+
restart: on-failure
17+
ports:
18+
- "5005:5005"
19+
depends_on:
20+
- postgres
21+
- redis_server
22+
- typesense
23+
24+
scheduler:
25+
build:
26+
context: ./
27+
dockerfile: Dockerfile.dev
28+
entrypoint: ["./cmd", "scheduler", "--config", "convoy.json"]
29+
volumes:
30+
- ./convoy.json:/convoy.json
31+
restart: on-failure
32+
depends_on:
33+
- postgres
34+
- redis_server
35+
36+
worker:
37+
build:
38+
context: ./
39+
dockerfile: Dockerfile.dev
40+
entrypoint: ["./cmd", "worker", "--config", "convoy.json"]
41+
volumes:
42+
- ./convoy.json:/convoy.json
43+
restart: on-failure
44+
depends_on:
45+
- postgres
46+
- redis_server
47+
48+
postgres:
49+
image: postgres:15.2-alpine
50+
restart: unless-stopped
51+
environment:
52+
POSTGRES_DB: convoy
53+
POSTGRES_USER: convoy
54+
POSTGRES_PASSWORD: convoy
55+
PGDATA: /data/postgres
56+
volumes:
57+
- ./postgres_data:/data/postgres
58+
59+
redis_server:
60+
image: redis:alpine
61+
restart: always
62+
volumes:
63+
- ./redis_data:/data
64+
65+
typesense:
66+
image: typesense/typesense:0.22.2
67+
restart: always
68+
environment:
69+
TYPESENSE_DATA_DIR: /data/typesense
70+
TYPESENSE_ENABLE_CORS: "true"
71+
TYPESENSE_API_KEY: "convoy"
72+
volumes:
73+
- ./typesense_data:/data/typesense
74+

0 commit comments

Comments
 (0)