Browse Source

Docker-compose with MongoDB (#796)

pull/1/head
Evgeny Smyshlyaev 5 years ago committed by rozetko
parent
commit
7f3df18068
  1. 16
      analytics/Dockerfile
  2. 49
      docker-compose-mongo.yml
  3. 12
      docker-compose.yml
  4. 12
      mongo-init.js
  5. 32
      server/Dockerfile

16
analytics/Dockerfile

@ -1,20 +1,12 @@
FROM python:3.6.6
WORKDIR /var/www/analytics
COPY ./requirements.txt /var/www/analytics
COPY requirements.txt /requirements.txt
RUN pip install -r requirements.txt \
&& apt-get update && apt-get install -y \
apt-utils \
gnupg \
curl \
make \
g++ \
git
RUN pip install -r /requirements.txt
VOLUME [ "/var/www/data" ]
WORKDIR /var/www/analytics
COPY . /var/www/analytics/
CMD ["python", "-u", "bin/server"]

49
docker-compose-mongo.yml

@ -0,0 +1,49 @@
version: '2.1'
services:
server:
image: hastic/server:latest
build:
dockerfile: server/Dockerfile
context: .
environment:
HASTIC_API_KEY: ${HASTIC_API_KEY?"HASTIC_API_KEY variable is required"}
GRAFANA_URL: ${GRAFANA_URL?"GRAFANA_URL variable is required"}
HASTIC_DB_CONNECTION_STRING: ${HASTIC_MONGO_USER:-hastic}:${HASTIC_MONGO_PASSWORD:-password}@mongo:27017/${HASTIC_MONGO_DB:-hastic}
ZMQ_CONNECTION_STRING: ${ZMQ_CONNECTION_STRING:-tcp://analytics:8002}
HASTIC_WEBHOOK_URL: ${HASTIC_WEBHOOK_URL}
HASTIC_WEBHOOK_TYPE: ${HASTIC_WEBHOOK_TYPE}
HASTIC_INSTANCE_NAME: ${HASTIC_INSTANCE_NAME}
HASTIC_WEBHOOK_IMAGE: ${HASTIC_WEBHOOK_IMAGE}
TIMEZONE_UTC_OFFSET: ${TIMEZONE_UTC_OFFSET}
HASTIC_DB_CONNECTION_TYPE: mongodb
ports:
- ${HASTIC_PORT:-8000}:8000
restart: always
depends_on:
- mongo
analytics:
image: hastic/analytics:latest
build: analytics
restart: always
mongo:
image: mongo:4.2.1-bionic
environment:
MONGO_INITDB_ROOT_USERNAME: ${HASTIC_MONGO_ADMIN_USER:-admin}
MONGO_INITDB_ROOT_PASSWORD: ${HASTIC_MONGO_ADMIN_PASSWORD:-password}
MONGO_INITDB_DATABASE: ${HASTIC_MONGO_DB:-hastic}
restart: always
volumes:
- hastic_mongo:/data/db
- hastic_mongo_config:/data/configdb
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
volumes:
hastic_mongo:
hastic_mongo_config:

12
docker-compose.yml

@ -6,16 +6,20 @@ services:
dockerfile: server/Dockerfile
context: .
environment:
HASTIC_API_KEY: ${HASTIC_API_KEY?"HASTIC_API_KEY variable is required"}
GRAFANA_URL: ${GRAFANA_URL?"GRAFANA_URL variable is required"}
ZMQ_CONNECTION_STRING: ${ZMQ_CONNECTION_STRING:-tcp://analytics:8002}
HASTIC_API_KEY: ${HASTIC_API_KEY}
HASTIC_WEBHOOK_URL: ${HASTIC_WEBHOOK_URL}
HASTIC_WEBHOOK_TYPE: ${HASTIC_WEBHOOK_TYPE}
GRAFANA_URL: ${GRAFANA_URL}
HASTIC_INSTANCE_NAME: ${HASTIC_INSTANCE_NAME}
HASTIC_WEBHOOK_IMAGE: ${HASTIC_WEBHOOK_IMAGE}
HASTIC_DB_CONNECTION_STRING: ${HASTIC_DB_CONNECTION_STRING}
HASTIC_DB_CONNECTION_TYPE: ${HASTIC_DB_CONNECTION_TYPE}
TIMEZONE_UTC_OFFSET: ${TIMEZONE_UTC_OFFSET}
ports:
- ${HASTIC_PORT:-8000}:8000
volumes:
@ -26,10 +30,6 @@ services:
image: hastic/analytics:latest
build: analytics
restart: always
command: ${HASTIC_ANALYTICS_COMMAND}
#set HASTIC_ANALYTICS_COMMAND="python -um ptvsd --host 0.0.0.0 --port 5678 bin/server" for remote debug
ports:
- 5678:5678
volumes:
data-volume:

12
mongo-init.js

@ -0,0 +1,12 @@
db.createUser(
{
user: "hastic",
pwd: "password",
roles: [
{
role: "readWrite",
db: "hastic"
}
]
}
);

32
server/Dockerfile

@ -1,23 +1,33 @@
FROM python:3.6.6
FROM node:8-alpine AS build
RUN apt-get install curl \
bash \
gnupg \
make \
g++ \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get update \
&& apt-get install nodejs
# tools for building zeromq
VOLUME [ "/var/www/data" ]
RUN apk add --no-cache curl gnupg make g++ bash python
# Note: context starts in directory above (see docker-compose file)
COPY server /var/www/server
COPY . /var/www
# copy git head file for current branch
# if nothing specified in `git_branch` arg then whole directory will be copied
COPY .git/refs/heads /var/www/.git/refs/heads
WORKDIR /var/www/server
RUN npm install
RUN npm run build
FROM node:8-alpine
# Note: context starts in directory above (see docker-compose file)
COPY .git/HEAD /var/www/.git/
COPY server/package.json /var/www/server/
WORKDIR /var/www/server
COPY --from=build /var/www/server/dist /var/www/server/dist
VOLUME ["/var/www/data"]
ENV INSIDE_DOCKER true
CMD ["npm", "start"]

Loading…
Cancel
Save