Merge pull request #44 from ketan/docker
Add support for docker & docker compose
This commit is contained in:
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.env
|
||||||
|
node_modules
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM node:lts-alpine
|
||||||
|
|
||||||
|
# add project files to /app
|
||||||
|
ADD ./ /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# install node dependencies
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
EXPOSE 8080
|
52
docker-compose.yml
Normal file
52
docker-compose.yml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
services:
|
||||||
|
|
||||||
|
# listens to mqtt packets and saves to database
|
||||||
|
meshtastic-mqtt:
|
||||||
|
container_name: meshtastic-mqtt
|
||||||
|
depends_on:
|
||||||
|
database:
|
||||||
|
condition: service_healthy
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./Dockerfile
|
||||||
|
command: /app/docker/mqtt.sh
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: "mysql://root:password@database:3306/meshtastic-map?connection_limit=100"
|
||||||
|
MQTT_OPTS: "" # add any custom mqtt.js options here
|
||||||
|
|
||||||
|
# runs the web map ui
|
||||||
|
meshtastic-map:
|
||||||
|
container_name: meshtastic-map
|
||||||
|
depends_on:
|
||||||
|
database:
|
||||||
|
condition: service_healthy
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./Dockerfile
|
||||||
|
command: /app/docker/map.sh
|
||||||
|
ports:
|
||||||
|
- 8080:8080/tcp
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: "mysql://root:password@database:3306/meshtastic-map?connection_limit=100"
|
||||||
|
MAP_OPTS: "" # add any custom index.js options here
|
||||||
|
|
||||||
|
# runs the database to store everything from mqtt
|
||||||
|
database:
|
||||||
|
container_name: database
|
||||||
|
image: bitnami/mariadb
|
||||||
|
ports:
|
||||||
|
- 3306:3306/tcp
|
||||||
|
environment:
|
||||||
|
MARIADB_DATABASE: "meshtastic-map"
|
||||||
|
MARIADB_ROOT_PASSWORD: "password"
|
||||||
|
volumes:
|
||||||
|
- database_data:/bitnami/mariadb
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD', '/opt/bitnami/scripts/mariadb/healthcheck.sh']
|
||||||
|
interval: 15s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 6
|
||||||
|
start_interval: 5s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
database_data:
|
7
docker/map.sh
Executable file
7
docker/map.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "Running migrations"
|
||||||
|
npx prisma migrate dev
|
||||||
|
|
||||||
|
echo "Starting map ui"
|
||||||
|
exec node src/index.js ${MAP_OPTS}
|
7
docker/mqtt.sh
Executable file
7
docker/mqtt.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "Running migrations"
|
||||||
|
npx prisma migrate dev
|
||||||
|
|
||||||
|
echo "Starting mqtt listener"
|
||||||
|
exec node src/mqtt.js ${MQTT_OPTS}
|
Reference in New Issue
Block a user