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

[docker, scorecard] add docker base image, use in scorecard #5623

Merged
merged 5 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
26 changes: 26 additions & 0 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:18.04

RUN apt-get update && \
apt-get -y install \
htop \
unzip bzip2 \
wget curl \
emacs25-nox \
default-jdk \
python3 python3-pip && \
rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install -U \
pip decorator pylint pytest flake8 \
requests \
jinja2 \
aiohttp aiodns aiohttp_jinja2 uvloop>=0.12 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add asyncinit? https://github.com/kchmck/pyasyncinit I'm going to use this for the MySQL PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

werkzeug flask flask-cors Flask_Sockets \
kubernetes google-cloud-storage \
PyGithub cerberus humanize libsass authlib

# source: https://cloud.google.com/storage/docs/gsutil_install#linux
RUN /bin/sh -c 'curl https://sdk.cloud.google.com | bash' && \
mv /root/google-cloud-sdk / && \
/google-cloud-sdk/bin/gcloud components install beta kubectl
ENV PATH $PATH:/google-cloud-sdk/bin
11 changes: 11 additions & 0 deletions docker/Dockerfile.spark-base
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM base

RUN wget -O spark-2.2.0-bin-hadoop2.7.tgz https://archive.apache.org/dist/spark/spark-2.2.0/spark-2.2.0-bin-hadoop2.7.tgz && \
tar xzf spark-2.2.0-bin-hadoop2.7.tgz && \
rm spark-2.2.0-bin-hadoop2.7.tgz

RUN wget -O /spark-2.2.0-bin-hadoop2.7/jars/gcs-connector-hadoop2-latest.jar https://storage.googleapis.com/hadoop-lib/gcs/gcs-connector-hadoop2-latest.jar
COPY core-site.xml /spark-2.2.0-bin-hadoop2.7/conf/core-site.xml

ENV SPARK_HOME /spark-2.2.0-bin-hadoop2.7
ENV PATH "$PATH:$SPARK_HOME/sbin:$SPARK_HOME/bin"
21 changes: 21 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.PHONY: build push deploy

PROJECT = $(shell gcloud config get-value project)

BASE_IMAGE = gcr.io/$(PROJECT)/base:$(shell docker images -q --no-trunc base:latest | sed -e 's,[^:]*:,,')
SPARK_BASE_IMAGE = gcr.io/$(PROJECT)/spark-base:$(shell docker images -q --no-trunc spark-base:latest | sed -e 's,[^:]*:,,')

build:
-docker pull ubuntu:18.04
-docker pull gcr.io/$(PROJECT)/base
-docker pull gcr.io/$(PROJECT)/spark-base
docker build . -t base -f Dockerfile.base --cache-from base,ubuntu:18.04
docker build . -t spark-base -f Dockerfile.spark-base --cache-from spark-base,base,ubuntu:18.04

push: build
docker tag base $(BASE_IMAGE)
docker push $(BASE_IMAGE)
docker tag spark-base $(SPARK_BASE_IMAGE)
docker push $(SPARK_BASE_IMAGE)

deploy: push
16 changes: 16 additions & 0 deletions docker/core-site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this file used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in the spark-base image to configure the Google hadoop connector.


<property>
<name>google.cloud.auth.service.account.enable</name>
<value>true</value>
</property>

<property>
<name>google.cloud.auth.service.account.json.keyfile</name>
<value>/hail-vdc-sa-key/hail-vdc-sa-key.json</value>
</property>

</configuration>
9 changes: 9 additions & 0 deletions docker/hail-ci-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -ex

gcloud -q auth activate-service-account \
--key-file=/secrets/gcr-push-service-account-key.json

gcloud -q auth configure-docker

make deploy
2 changes: 2 additions & 0 deletions projects.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- project: docker
- project: auth-gateway
- project: batch
- project: ci
Expand All @@ -15,6 +16,7 @@
- project: pipeline
dependencies: ["batch"]
- project: scorecard
dependencies: ["docker"]
- project: site
- project: upload
- project: vdc
10 changes: 2 additions & 8 deletions scorecard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
FROM continuumio/miniconda
MAINTAINER Hail Team <[email protected]>

COPY environment.yml .
RUN conda env create scorecard -f environment.yml && \
rm -f environment.yml && \
rm -rf /home/root/.conda/pkgs/*
FROM base

COPY scorecard /scorecard

EXPOSE 5000

CMD ["bash", "-c", "source activate scorecard; python /scorecard/scorecard.py"]
CMD ["bash", "-c", "python3 /scorecard/scorecard.py"]
15 changes: 8 additions & 7 deletions scorecard/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

PROJECT = $(shell gcloud config get-value project)

SCORECARD_IMAGE = gcr.io/$(PROJECT)/scorecard:$(shell docker images -q --no-trunc scorecard:latest | sed -e 's,[^:]*:,,')

build:
docker build . -t scorecard
-docker pull gcr.io/$(PROJECT)/scorecard
docker build . -t scorecard --cache-from scorecard,base,ubuntu:18.04

push: IMAGE = gcr.io/$(PROJECT)/scorecard:$(shell docker images -q --no-trunc scorecard | sed -e 's,[^:]*:,,')
push: build
echo $(IMAGE) > scorecard-image
docker tag scorecard $(IMAGE)
docker push $(IMAGE)
docker tag scorecard $(SCORECARD_IMAGE)
docker push $(SCORECARD_IMAGE)

run-docker: build
docker run -i -p 5000:5000 -v secrets:/secrets -t scorecard
docker run -i -p 5000:5000 -v `pwd`/secrets:/secrets -t scorecard

run:
GITHUB_TOKEN_PATH=secrets/scorecard-github-access-token.txt python scorecard/scorecard.py

deploy: push
sed -e "s,@sha@,$(shell git rev-parse --short=12 HEAD)," \
-e "s,@image@,$(shell cat scorecard-image)," \
-e "s,@image@,$(SCORECARD_IMAGE)," \
< deployment.yaml.in > deployment.yaml
kubectl -n default apply -f deployment.yaml
9 changes: 0 additions & 9 deletions scorecard/environment.yml

This file was deleted.