Skip to content

Commit f1724a8

Browse files
committed
chore: docker comose for prod and development add, dockerfile updated
The dockerfile updated to migitate dotenvx private key error.
1 parent cab3082 commit f1724a8

5 files changed

Lines changed: 204 additions & 3 deletions

File tree

auth-svc/dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ EXPOSE 5859
2121
CMD [ "bun", "run", "dev" ]
2222

2323
FROM base AS release
24+
RUN curl -sfS https://dotenvx.sh | sh
2425
WORKDIR /usr/auth-svc
2526
COPY --from=install /temp/prod/node_modules /usr/auth-svc/node_modules
2627
COPY . .
2728
RUN bun run build
2829

2930
EXPOSE 5858
30-
CMD [ "bun", "run" , "start" ]
31+
CMD [ "dotenvx", "run" , "-f", ".env.production", "--", "bun", "./dist/user-server.mjs" ]

compose.dev.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
services:
2+
authsvc-build:
3+
build:
4+
context: ./auth-svc
5+
target: prerelease
6+
image: authsvc-dev:latest
7+
command : ["bun", "run", "prisma-dev", "migrate", "dev"]
8+
environment:
9+
- DOTENV_PRIVATE_KEY_DEVELOPMENT
10+
networks:
11+
- authnet
12+
depends_on:
13+
db-authsvc:
14+
condition: service_healthy
15+
16+
authsvc:
17+
build:
18+
context: ./auth-svc
19+
target: prerelease
20+
image: authsvc-dev:latest
21+
environment:
22+
- DOTENV_PRIVATE_KEY_DEVELOPMENT
23+
networks:
24+
- authnet
25+
- svcnet
26+
depends_on:
27+
authsvc-build:
28+
condition: service_completed_successfully
29+
30+
db-authsvc:
31+
image: postgres:alpine
32+
environment:
33+
- POSTGRES_PASSWORD={$AUTH_DB_PASSWORD}
34+
- POSTGRES_USER={$AUTH_DB_USER}
35+
- POSTGRES_DB={$AUTH_DB}
36+
healthcheck:
37+
test: ["CMD-SHELL", "pg_isready -U authsvc -d authsvc"]
38+
interval: 3s
39+
timeout: 3s
40+
retries: 3
41+
networks:
42+
- authnet
43+
volumes:
44+
- data-authsvc:/var/lib/postgresql
45+
46+
userpost-build:
47+
build:
48+
context: ./post-svc
49+
target: prerelease
50+
image: userpost-dev:latest
51+
command : ["bun", "run", "postbuild-dev"]
52+
environment:
53+
- DOTENV_PRIVATE_KEY_DEVELOPMENT
54+
networks:
55+
- frontnet
56+
depends_on:
57+
db-userpost:
58+
condition: service_healthy
59+
60+
61+
userposts:
62+
build:
63+
context: ./post-svc
64+
target: prerelease
65+
image: userpost-dev:latest
66+
ports:
67+
- 3000:3000
68+
environment:
69+
- DOTENV_PRIVATE_KEY_DEVELOPMENT
70+
networks:
71+
- frontnet
72+
- svcnet
73+
depends_on:
74+
userpost-build:
75+
condition: service_completed_successfully
76+
authsvc:
77+
condition: service_started
78+
79+
80+
db-userpost:
81+
image: postgres:alpine
82+
environment:
83+
- POSTGRES_PASSWORD={$POST_DB_PASS}
84+
- POSTGRES_USER={$POST_DB_USER}
85+
- POSTGRES_DB={$POST_DB}
86+
healthcheck:
87+
test: ["CMD-SHELL", "pg_isready -U userpost -d userpost"]
88+
interval: 3s
89+
timeout: 3s
90+
retries: 3
91+
networks:
92+
- frontnet
93+
volumes:
94+
- data-userpost:/var/lib/postgresql
95+
networks:
96+
frontnet:
97+
authnet:
98+
svcnet:
99+
volumes:
100+
data-userpost:
101+
data-authsvc:
102+

compose.prod.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
services:
2+
authsvc-build:
3+
build:
4+
context: ./auth-svc
5+
image: authsvc-prod:latest
6+
command : ["bun", "run", "prisma-pro", "migrate", "deploy"]
7+
environment:
8+
- DOTENV_PRIVATE_KEY_PRODUCTION
9+
networks:
10+
- authnet
11+
depends_on:
12+
db-authsvc:
13+
condition: service_healthy
14+
15+
authsvc:
16+
image: authsvc-prod:latest
17+
environment:
18+
- DOTENV_PRIVATE_KEY_PRODUCTION
19+
networks:
20+
- authnet
21+
- svcnet
22+
depends_on:
23+
authsvc-build:
24+
condition: service_completed_successfully
25+
26+
db-authsvc:
27+
image: postgres:alpine
28+
environment:
29+
- POSTGRES_PASSWORD={$AUTH_DB_PASS}
30+
- POSTGRES_USER={$AUTH_DB_USER}
31+
- POSTGRES_DB={$AUTH_DB}
32+
healthcheck:
33+
test: ["CMD-SHELL", "pg_isready -U authsvc -d authsvc"]
34+
interval: 3s
35+
timeout: 3s
36+
retries: 3
37+
networks:
38+
- authnet
39+
volumes:
40+
- data-authsvc:/var/lib/postgresql
41+
42+
userpost-build:
43+
build:
44+
context: ./post-svc
45+
46+
image: userpost-prod:latest
47+
command : ["bun", "run", "postbuild-pro"]
48+
environment:
49+
- DOTENV_PRIVATE_KEY_PRODUCTION
50+
networks:
51+
- frontnet
52+
depends_on:
53+
db-userpost:
54+
condition: service_healthy
55+
56+
57+
userposts:
58+
image: userpost-prod:latest
59+
ports:
60+
- 3000:3000
61+
environment:
62+
- DOTENV_PRIVATE_KEY_PRODUCTION
63+
networks:
64+
- frontnet
65+
- svcnet
66+
depends_on:
67+
userpost-build:
68+
condition: service_completed_successfully
69+
authsvc:
70+
condition: service_started
71+
72+
73+
db-userpost:
74+
image: postgres:alpine
75+
environment:
76+
- POSTGRES_PASSWORD={$POST_DB_PASS}
77+
- POSTGRES_USER={$POST_DB_USER}
78+
- POSTGRES_DB={$POST_DB}
79+
healthcheck:
80+
test: ["CMD-SHELL", "pg_isready -U userpost -d userpost"]
81+
interval: 3s
82+
timeout: 3s
83+
retries: 3
84+
networks:
85+
- frontnet
86+
volumes:
87+
- data-userpost:/var/lib/postgresql
88+
networks:
89+
frontnet:
90+
authnet:
91+
svcnet:
92+
volumes:
93+
data-userpost:
94+
data-authsvc:
95+

post-svc/dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ EXPOSE 3000
2121
CMD [ "bun", "run", "dev" ]
2222

2323
FROM base AS release
24+
RUN curl -sfS https://dotenvx.sh | sh
2425
WORKDIR /usr/post-svc
2526
COPY --from=install /temp/prod/node_modules /usr/post-svc/node_modules
2627
COPY . .
2728
RUN bun run build
2829

2930
EXPOSE 3000
30-
CMD [ "bun", "run" , "start" ]
31+
CMD [ "dotenvx", "run" , "-f", ".env.production", "--", "bun", "./dist/app.mjs" ]
32+

post-svc/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"init-pics-dev": "dotenvx run --env-file=.env.development -- bun ./src/models/set-prisma-pics.mjs",
1515

1616
"build": "bun run prisma-pro generate && tsc && bun run copy-assets",
17-
"post-build-dev": "bun run prisma-dev migrate dev && bun run init-catg-dev",
17+
"postbuild-dev": "bun run prisma-dev migrate dev && bun run init-catg-dev",
18+
"postbuild-pro": "bun run prisma-pro migrate deploy && bun run init-catg-pro",
1819
"copy-assets": "cp -r src/public/assets dist/public; cp -r src/views dist/; cp -r src/partials dist/",
1920

2021
"init-catg-pro": "dotenvx run --env-file=.env.production --overload -- bun ./dist/models/init-categories.mjs ",

0 commit comments

Comments
 (0)