Skip to content

Commit f869048

Browse files
committed
to replicate user service
1 parent f5ff323 commit f869048

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

backend/question/entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ npm run db:prod:migrate
66
# Checks admin table and will not seed if data exists
77
npm run db:prod:seed
88

9-
npm run start
9+
rm -rf drizzle src tsconfig.json
10+
11+
npm uninstall tsx drizzle-kit
12+
13+
npm run start

backend/question/express.Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@ FROM node:lts-alpine AS build
22
WORKDIR /data/question-express
33
COPY package*.json ./
44
RUN npm install
5+
ARG env
56
COPY . .
67
RUN npm run build
78

89
FROM node:lts-alpine AS production
910
WORKDIR /data/question-express
1011
COPY --from=build /data/question-express/package*.json ./
11-
RUN npm ci --omit=dev
1212
COPY --from=build --chown=node:node /data/question-express/dist ./dist
1313

14+
RUN npm ci --omit=dev
15+
16+
# For migration
17+
RUN npm install tsx drizzle-kit
18+
COPY drizzle ./drizzle
19+
COPY src/lib/db/ ./src/lib/db
20+
COPY src/config.ts ./src
21+
COPY tsconfig.json .
22+
COPY entrypoint.sh .
23+
24+
1425
ARG port
1526
EXPOSE ${port}
16-
CMD [ "npm", "run", "start" ]
27+
ENTRYPOINT [ "/bin/sh", "entrypoint.sh" ]

docker-compose.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,39 @@ services:
9898
retries: 5
9999
start_period: 5s
100100

101+
question-service:
102+
image: "question-express"
103+
container_name: "question-express"
104+
build:
105+
context: ./backend/question
106+
dockerfile: express.Dockerfile
107+
target: production
108+
args:
109+
# For building with the correct env vars
110+
- env=${QUESTION_EXPRESS_ENV}
111+
- port=${QUESTION_EXPRESS_PORT}
112+
ports:
113+
- "9002:${QUESTION_EXPRESS_PORT}"
114+
env_file:
115+
- ./backend/question/.env.compose
116+
environment:
117+
# Docker Compose Specific for Service Discovery
118+
- EXPRESS_DB_HOST=question-db
119+
- EXPRESS_DB_PORT=5432
120+
depends_on:
121+
question-db:
122+
condition: service_healthy
123+
restart: true
124+
networks:
125+
- question-db-network
126+
- question-api-network
127+
healthcheck:
128+
test: wget --no-verbose --tries=1 --spider http://localhost:9002/health || exit 1
129+
interval: 30s
130+
timeout: 10s
131+
retries: 5
132+
start_period: 5s
133+
101134
volumes:
102135
# Persistent Volumes for Databases
103136
user-db-docker:

0 commit comments

Comments
 (0)