Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Initial docker and docker-compose implementation #180

Merged
merged 1 commit into from
Aug 9, 2019
Merged
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
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Dynalite
*.out

# OSX
.DS_Store

# doit
.doit.db

# Virtual Environment
venv

# Eggs
.eggs
subhub.egg-info

# Node
node_modules

# Visual Studio Code
.vscode

# PyCharm
.idea

.vscode/
.tox
venv
.doit.db
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ language: python
dist: xenial
python:
- "3.7"
services:
- docker
env:
global:
- AWS_DEFAULT_REGION: us-west-2
Expand All @@ -13,6 +15,7 @@ env:
- secure: eIOTi2ri6Y07/lqulILb6wQDC3SiZkiEPALG22icnOMQJJc7iSQCatyxZAze4M1aZRoQ3RgvKcftLFFB55JtXKwAoeQMU2eLSls31weKU4WgBqDwItJaKbbeDM/tBUYKel1rocx1rjxAGB/l4/YavlLwVyVOuA3MZ/bRbBEyBWsTJsdSpSUmEjXmWEcrk4ielMxZYBjbvSpa++FDDQvxSPzt5xeu66fa885i1u95MSNuaCJa3zkcueopEu1k/PA/IpqBr4Ga5llKer3epnByyy35JOnfBC4GC/Pu4B/520NaAj1YFP2Fuz9ZifSm9+E3iwHV1Ui87Xft8c3Qu0nIev9n9s3VUIq40Q5nWTmL9lolULdnQdWW5spHyKZGZKO4lX66KNe7Pj/B+58FUNYTzNkxhM1K1361QDrF9isgNgE/yCIcM4jeDHuZcnw0yjJe5b5Rv/RMIaEL/tz7DUSFKIWxbS6ESBVSyBoyxcph9b0mWH1LIKTWtFbFMS35Fxt962ozPmK/Wq+SXOfdPk7Um4Jz3o3/T12hFfcaqwXkeMtqRioq+m67+tYdWRUcflVyrXP4c3z5obLlo3t3bWRKSrr3ca5j60yxt+wbD+jt53A4hR9jrlRXsiMlm4T0GOE10loF2rYIzrnL+2yOD8cpaKG0StqLh4IUYeJk4X7WtlY=
- secure: SGLE6u5bXFchF9jCtiiuYkp3Eyz7ghwyS7TvHcfv6SBsA1QGXPyVUsU9QcoLB3srajwvponYOLAyynD+tG9AdqgvmueRpUh+h3qckU1NPfDUEefkJ9zdYcT+n7TCGBYePRuYUbLMtRvX8NDUb9LTD3U+u80L53UjFfTrRQH8csE4tfOiqpPrzbKAMBnrl7fyBWHCwjkICoce01wEEp2+T4b6Sq/qWUkKrPn6KBnHO3Ev+WtEPGcF9pMrhdwkV8vsA8C9KYffDbT7s3dAlZIhEtIhD1komqMYdfTuokVyRlrWqcG4g++7/ZPGYCtFTpPx8o3qQfoLhgKMe7oOs+WivqmFtsOV6JywDDR4brBQI3lUtRK2yIrBhdhC/BAogol8g1A5asPL2uGPJtrc4O4E1x5mGgDJLtpefM3zWOqdXiL6YGz0MYZA3hgZxLj2uVHj97pzxPZbZgyrwO6LtH0hbwTxF1L9/Ha42jPEtnjmu6fvygSaQXtjot6saCSIMZBGwYWmk5ckcZ3zgI+G9R9G0eIRwap/mKElmgQX46BqsC/npQWHTQNcv5UmMtFAFRdT76gnWS9NanvOZO3mxreo9q+cyt7yz7TS2bZpNesU1GqLF6mmyWjvJP4FsEB1JhzW+yfAK8+1xnIcRxw8n/XA6x5ZAiJLD5+2M4ukucwj8aM=


before_install:
- python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL);
fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
Expand All @@ -23,11 +26,12 @@ before_install:
- npm install -g dynalite
- npm install -g kinesalite
- sudo apt-get install -y graphviz graphviz-dev awscli
- "./scripts/aws_credentials.sh"
- "./bin/aws-credentials.sh"

stages:
- name: Graph
- name: Unit Test
- name: Docker Build

jobs:
include:
Expand All @@ -37,4 +41,7 @@ jobs:
- doit draw
- stage: Unit Test
script:
- doit test
- doit test
- stage: Docker Build
script:
- docker-compose build
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM python:3.7-alpine
MAINTAINER Stewart Henderson <shenderson@mozilla.com>

ARG STRIPE_API_KEY
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG LOCAL_FLASK_PORT
ARG SUPPORT_API_KEY

ENV STRIPE_API_KEY=$STRIPE_API_KEY
ENV AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
ENV AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
ENV LOCAL_FLASK_PORT=$LOCAL_FLASK_PORT
ENV SUPPORT_API_KEY=$SUPPORT_API_KEY
ENV FLASK_ENV=development

EXPOSE $LOCAL_FLASK_PORT

RUN mkdir -p /subhub
WORKDIR /subhub
COPY . /subhub
RUN apk add bash==5.0.0-r0 && \
bin/install-packages.sh && \
pip install -r automation_requirements.txt && \
pip install awscli==1.16.213
RUN yarn install
RUN addgroup -g 10001 subhub && \
adduser -D -G subhub -h /subhub -u 10001 subhub
USER subhub
ENTRYPOINT ["doit"]
CMD ["local"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ This command will generate a PNG of the dependency graph.
doit draw
```

### Docker
* build: `docker build -t mozilla/subhub .`
* run: `docker run -it mozilla/subhub`

### Docker Compose
* build and run: `docker-compose up --build`
* run: `docker-compose up`

## Postman

A [Postman](https://www.getpostman.com/) URL collection is available for testing, learning,
Expand Down
19 changes: 19 additions & 0 deletions bin/aws-credentials.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# NOTE: This script is used to provision both TravisCI and Jenkins, AWS credentials and configuration
# Reference AWS Environment Variables
# https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html

mkdir -p ~/.aws

cat > ~/.aws/credentials << EOL
[default]
aws_access_key_id = ${AWS_ACCESS_KEY_ID:-fake-id}
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY:-fake-key}
EOL

cat >~/.aws/config <<-EOF
[default]
output=json
region=${AWS_DEFAULT_REGION:-us-west-2}
EOF
8 changes: 8 additions & 0 deletions bin/install-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# Alpine Registry for package versions, https://pkgs.alpinelinux.org/packages
apk update

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
IFS=$'\n' read -d '' -r -a lines < "${DIR}/../etc/alpine-packages"
apk add --no-cache "${lines[@]}"
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.7"

services:
subhub:
container_name: subhub
image: mozilla/subhub
# The `command` section below can take any command from
# `doit list` and run them here.
command: local
build:
context: .
args:
AWS_ACCESS_KEY_ID: "fake-id"
AWS_SECRET_ACCESS_KEY: "fake-key"
STRIPE_API_KEY: "sk_test_123"
SUPPORT_API_KEY: "support_test"
LOCAL_FLASK_PORT: 5000
ports:
- "5000:5000"
claudiouzelac marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,4 +707,4 @@ def task_draw():
'file_dep': ['tasks.dot'],
'targets': ['tasks.png'],
'actions': ['dot -Tpng %(dependencies)s -o %(targets)s'],
}
}
18 changes: 18 additions & 0 deletions etc/alpine-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
build-base==0.5-r1
libgit2-dev==0.28.2-r0
libc-dev==0.7.1-r0
python3-dev==3.7.3-r0
libffi-dev==3.2.1-r6
openssl-dev==1.1.1c-r0
zeromq-dev==4.3.2-r1
linux-headers==4.19.36-r0
nodejs==10.16.0-r0
curl==7.65.1-r0
yarn==1.16.0-r0
gcc==8.3.0-r0
g++==8.3.0-r0
musl-dev==1.1.22-r3
pkgconfig
git==2.22.0-r0
graphviz-dev==2.40.1-r1
graphviz==2.40.1-r1
9 changes: 0 additions & 9 deletions scripts/aws_credentials.sh

This file was deleted.

2 changes: 1 addition & 1 deletion subhub/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PyYAML==5.1.1
requests==2.22.0
s3transfer==0.2.1
six==1.12.0
stripe==2.32.1
stripe==2.33.0
claudiouzelac marked this conversation as resolved.
Show resolved Hide resolved
structlog==19.1.0
urllib3==1.25.3
pyinstrument==3.0.3
Expand Down