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

Update Docker build to use python3 #122

Open
wants to merge 2 commits into
base: master
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM alpine:latest as py-ea
ARG ELASTALERT_VERSION=v0.2.0b2
FROM python:3.6-alpine as py-ea
ARG ELASTALERT_VERSION=v0.2.1
ENV ELASTALERT_VERSION=${ELASTALERT_VERSION}
# URL from which to download Elastalert.
ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSION.zip
Expand All @@ -9,7 +9,7 @@ ENV ELASTALERT_HOME /opt/elastalert

WORKDIR /opt

RUN apk add --update --no-cache ca-certificates openssl-dev openssl python2-dev python2 py2-pip py2-yaml libffi-dev gcc musl-dev wget && \
RUN apk add --update --no-cache ca-certificates openssl-dev openssl libffi-dev gcc musl-dev wget && \
# Download and unpack Elastalert.
wget -O elastalert.zip "${ELASTALERT_URL}" && \
unzip elastalert.zip && \
Expand All @@ -21,19 +21,19 @@ WORKDIR "${ELASTALERT_HOME}"
# Install Elastalert.
# see: https://github.com/Yelp/elastalert/issues/1654
RUN sed -i 's/jira>=1.0.10/jira>=1.0.10,<1.0.15/g' setup.py && \
python setup.py install && \
pip install -r requirements.txt
python3 setup.py install && \
pip3 install -r requirements.txt

FROM node:alpine
LABEL maintainer="BitSensor <dev@bitsensor.io>"
# Set timezone for this container
ENV TZ Etc/UTC

RUN apk add --update --no-cache curl tzdata python2 make libmagic
RUN apk add --update --no-cache curl tzdata python2 python3 make libmagic

COPY --from=py-ea /usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages
COPY --from=py-ea /usr/local/lib/python3.6/site-packages /usr/lib/python3.6/site-packages
COPY --from=py-ea /opt/elastalert /opt/elastalert
COPY --from=py-ea /usr/bin/elastalert* /usr/bin/
COPY --from=py-ea /usr/local/bin/elastalert* /usr/bin/

WORKDIR /opt/elastalert-server
COPY . /opt/elastalert-server
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
v ?= v0.2.0b2
v ?= v0.2.1

all: build

build:
docker pull alpine:latest && docker pull node:alpine
docker build --build-arg ELASTALERT_VERSION=$(v) -t elastalert .
docker build --build-arg ELASTALERT_VERSION=$(v) -t elastalert-python3 .

server: build
docker run -it --rm -p 3030:3030 \
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/process/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class ProcessController {

// Create ElastAlert index if it doesn't exist yet
logger.info('Creating index');
var indexCreate = spawnSync('python', ['-m', 'elastalert.create_index', '--index', config.get('writeback_index'), '--old-index', ''], {
var indexCreate = spawnSync('python3', ['-m', 'elastalert.create_index', '--index', config.get('writeback_index'), '--old-index', ''], {
cwd: this._elastalertPath
});

Expand Down Expand Up @@ -92,7 +92,7 @@ export default class ProcessController {

logger.info('Starting elastalert with arguments ' + (startArguments.join(' ') || '[none]'));

this._process = spawn('python', ['-m', 'elastalert.elastalert'].concat(startArguments), {
this._process = spawn('python3', ['-m', 'elastalert.elastalert'].concat(startArguments), {
cwd: this._elastalertPath
});

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class TestController {


try {
let testProcess = spawn('python', processOptions, {
let testProcess = spawn('python3', processOptions, {
cwd: self._elastalertPath
});

Expand Down