Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] dockerized #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
firebase-adminsdk.json
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:lts as base

WORKDIR /app
COPY package.json .
RUN npm install

FROM base as build
COPY . .
# FIXME: tsc doesn't have --transpile-only flag. (https://github.com/microsoft/TypeScript/issues/29651)
# RUN npm run build

# FROM base as run
# COPY --from=build /app/build ./build

# NOTE: ./src/config/index.ts checks the existence of `.env` file.
RUN touch .env

ARG PORT=7575
ENV PORT $PORT
EXPOSE $PORT

# FIXME: tsc doesn't have --transpile-only flag. (ditto)
# CMD node build/app
CMD npm start -- --exitcrash
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ You should then be able to start the server using:
npm start
```

Or, you can build and start the server via docker-compose:

```sh
docker compose --profile prod --env-file .env up -d
```


## FCM Setup
Expand Down Expand Up @@ -97,7 +102,7 @@ curl --location --request POST 'https://<delivery_node_url>/apis/v1/pushtokens/r

## Upcoming features

- Dockerization
- [x] Dockerization
- Analytics
- Video Tutorials
- Monitoring APIs
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ services:
# Change this to your local path
volumes:
- ./external/mysql:/var/lib/mysql/
networks:
- main

phpmyadmin:
image: phpmyadmin/phpmyadmin
Expand All @@ -37,6 +39,35 @@ services:
restart: always
ports:
- 8182:80

push-delivery-node:
build: .
profiles:
- prod
restart: always
networks:
- main
ports:
- 80:${PORT}
volumes:
- ./firebase-adminsdk.json:/app/firebase-adminsdk.json:ro
environment:
NODE_ENV: ${NODE_ENV}
PORT: ${PORT}
LOG_LEVEL: ${LOG_LEVEL}
DELIVERY_NODES_NET: ${DELIVERY_NODES_NET}
DELIVERY_NODE_DB_HOST: db2
DELIVERY_NODE_DB_PORT: 3306
DELIVERY_NODE_DB_NAME: ${DELIVERY_NODE_DB_NAME}
DELIVERY_NODE_DB_USER: ${DELIVERY_NODE_DB_USER}
DELIVERY_NODE_DB_PASS: ${DELIVERY_NODE_DB_PASS}
FIREBASE_DATABASE_URL: ${FIREBASE_DATABASE_URL}
PUSH_NODE_WEBSOCKET_URL: ${PUSH_NODE_WEBSOCKET_URL}
REDIS_URL: redis://redis:6379
depends_on:
- mysql
- redis

networks:
main:
driver: bridge