Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Fix kubernetes mode (#906)
Browse files Browse the repository at this point in the history
* fixed default port not being given in dockerfile for games

* Changed simulation runner to make use of asyncio

* changed parallel_map to async_map

* Waiting for workers pt. 1

* aimmo now works in kubernetes mode again

* aimmo now works in kubernetes mode again (tests fails though)

* Merge remote-tracking branch 'origin/fix_kubernetes_mode' into fix_kubernetes_mode

* fixed broken tests

* pep8

* removed temporary logging

* moved get loop into setUp for tests

* bump version++

* make runner last build stage

* remove broken coverage tool

* removed broken coverage tool++

* change docker build target in tester

* docker now uses buildkit (requires docker 18.09)

* create build hook for docker cloud

* fix syntax error

* add image tag to build hook

* fix image name on build hook

* add build hook for worker and game-creator

* remove pwd from build hooks

* remove broken coverage tool from travis.yml

* change env variable to be str not int

* force setup.py version

* Revert "force setup.py version"

This reverts commit 306bee8.

* review changes

* add dockerbuildkit env variable to travis

* change the way docker is installed for travis test

* removed docker addon from travis.yml (installing older version)

* changed logic in docker scripts
  • Loading branch information
TheseusGrey committed Nov 29, 2018
1 parent 45a966e commit 54e2596
Show file tree
Hide file tree
Showing 28 changed files with 205 additions and 350 deletions.
17 changes: 5 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- docker
env:
global:
- DOCKER_BUILDKIT=1
- secure: "TNhj8oXrtBzCkkJDA8qbDmqUggK9Kbsy8Itgi0+VmXB+3bVRornZMS38ppaFz+BVOTdL80ZvN2s/OPV106QjFv0Hx1MmWAw4kNST2QBtxFXBHRKYtr7NtBN0jr11el1fG83YdpeZYQbc5aqbJ4OPz2GpfhGfDVhVGPjMFMKXI5XbTbbl+HCEL67ywozt964LhpuuXTaX7jgYFiJUtcwkYRUaDYY3ryJvMSOx95AjKyRMNC5JlgAqbJuYsOTm1eVZtfQ1jYVvd/NuAHOMDNpZWvcIaxTuc3k4XZh4UPryuRJWfjgjIq6kua7Q6ho6W2GbDgN2b/9lIldkTR8QfLSnCNLJIg6KJZ2gmIQg7u+nZHemdugo9XkvfmKXfB/t3HChFX1HNtS4gSeIn874IynLHx3UJ1lxm7BdDbF4Jjijffj5uWDGqVj3/Myd2jdFTJCoLJXvYI7la6ouMzXW5aDFhy2UXK2A3q7aBbaD64+U1R7YPGIyvfAd7NCF11vtRvJGI/fNjO5S1EuSacrQm7CiXu0rd0L5EOSU85XNTQsWN6xxJKEcc8Hx9YLRXkmR7gK9LoEPTUwFbfVXBUvnOsZav3MOBBxzj4+eLxkx2B1vbY2Lx5yPAqyWwi3vet46NEZUIKgqK+xRYQKj6dj3OF1gx7LOcyhpyevdpTZotiEx0C4=" # SNAP_API_AUTH
git:
depth: 9999999 # Building untagged builds needs enough depth to get the latest tag
Expand Down Expand Up @@ -45,39 +46,31 @@ jobs:
- node djangoBundler.js
- popd
script:
- python all_tests.py --no-docker-container-tests --coverage
after_success:
- coveralls
- python all_tests.py --no-docker-container-tests
- name: "aimmo-game"
before_install:
- cd aimmo-game
- docker build -t ocadotechnology/aimmo-game:test .
- docker build --target tester -t ocadotechnology/aimmo-game:test .
install:
- pip install coveralls
script:
- docker run -it -p 5000:5000 ocadotechnology/aimmo-game:test
after_success:
- coveralls
- name: "aimmo-game-creator"
before_install:
- cd aimmo-game-creator
- docker build -t ocadotechnology/aimmo-game-creator:test .
- docker build --target tester -t ocadotechnology/aimmo-game-creator:test .
install:
- pip install coveralls
script:
- docker run -it -p 5000:5000 ocadotechnology/aimmo-game-creator:test
after_success:
- coveralls
- name: "aimmo-game-worker"
before_install:
- cd aimmo-game-worker
- docker build -t ocadotechnology/aimmo-game-worker:test .
- docker build --target tester -t ocadotechnology/aimmo-game-worker:test .
install:
- pip install coveralls
script:
- docker run -it -p 5000:5000 ocadotechnology/aimmo-game-worker:test
after_success:
- coveralls
- name: "Javascript Tests"
before_install:
- nvm install node
Expand Down
10 changes: 0 additions & 10 deletions aimmo-game-creator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,16 @@ MAINTAINER code@ocado.com
# RUN apk add --no-cache gcc musl-dev python-dev libffi-dev openssl-dev
RUN pip install pipenv
COPY ["Pipfile", "Pipfile.lock", "setup.py", "./"]
RUN pipenv install coverage
RUN pipenv install --system --deploy

FROM python:3.6-alpine as base
COPY --from=builder /usr/local/lib/python3.6/site-packages /usr/local/lib/python3.6/site-packages
COPY . .


FROM base as runner
ENV WORKER_MANAGER=kubernetes
CMD ["python", "./service.py", "0.0.0.0"]


FROM base as tester
ENV WORKER_MANAGER=kubernetes
CMD ["python", "setup.py", "test"]

FROM base as coverage_tester
ENV WORKER_MANAGER=kubernetes
ENV WITH_COVERAGE='True'
RUN apk add bash
COPY --from=builder /usr/local/bin/coverage /usr/local/bin/coverage
CMD python setup.py test
1 change: 0 additions & 1 deletion aimmo-game-creator/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ name = "pypi"
kubernetes = "*"
aimmo-game-creator = {editable = true, path = "."}
docker = "*"
coverage = "*"

[requires]
python_version = "3.6.7"
79 changes: 21 additions & 58 deletions aimmo-game-creator/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions aimmo-game-creator/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker build --target runner -t $IMAGE_NAME .
13 changes: 0 additions & 13 deletions aimmo-game-creator/setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
# -*- coding: utf-8 -*-
from setuptools import find_packages, setup
import coverage
import sys
import os


withcoverage = os.environ.get('WITH_COVERAGE')

if withcoverage == 'True':
print("starting code coverage engine")
coveragedatafile = ".coverage"
cov = coverage.Coverage(config_file=False)
cov.start()


setup(
name='aimmo-game-creator',
packages=find_packages(),
Expand All @@ -28,8 +20,3 @@
test_suite='tests',
zip_safe=False,
)

if withcoverage == 'True':
print("saving coverage stats")
cov.save()
print("exiting program")
9 changes: 0 additions & 9 deletions aimmo-game-worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ MAINTAINER code@ocado.com

RUN pip install pipenv
COPY ["Pipfile", "Pipfile.lock", "setup.py", "./"]
RUN pipenv install coverage
RUN pipenv install --system --deploy

FROM python:3.6-alpine as base
Expand All @@ -13,16 +12,8 @@ COPY . .
FROM base as runner
ENV WORKER_MANAGER=kubernetes
ENV FLASK_ENV='development'
RUN apk add --no-cache bash
CMD python ./service.py 0.0.0.0 $PORT $DATA_URL

FROM base as tester
ENV WORKER_MANAGER=kubernetes
CMD python setup.py test

FROM base as coverage_tester
ENV WORKER_MANAGER=kubernetes
ENV WITH_COVERAGE='True'
RUN apk add bash
COPY --from=builder /usr/local/bin/coverage /usr/local/bin/coverage
CMD python setup.py test
40 changes: 20 additions & 20 deletions aimmo-game-worker/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions aimmo-game-worker/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker build --target runner -t $IMAGE_NAME .
12 changes: 0 additions & 12 deletions aimmo-game-worker/setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# -*- coding: utf-8 -*-
from setuptools import find_packages, setup
import coverage
import sys
import os


withcoverage = os.environ.get('WITH_COVERAGE')

if withcoverage == 'True':
print("starting code coverage engine")
coveragedatafile = ".coverage"
cov = coverage.Coverage(config_file=False)
cov.start()

setup(
name='aimmo-game-worker',
packages=find_packages(),
Expand All @@ -28,8 +21,3 @@
test_suite='tests',
zip_safe=False,
)

if withcoverage == 'True':
print("saving coverage stats")
cov.save()
print("exiting program")
14 changes: 2 additions & 12 deletions aimmo-game/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
FROM python:3.6 as builder
MAINTAINER code@ocado.com

RUN pip install pipenv
COPY ["Pipfile", "Pipfile.lock", "setup.py", "./"]
RUN pipenv install coverage
RUN pipenv install --system --deploy

FROM python:3.6-alpine as base
COPY --from=builder /usr/local/lib/python3.6/site-packages /usr/local/lib/python3.6/site-packages
COPY . .

FROM base as runner
RUN apk add --no-cache bash
ENV WORKER_MANAGER=kubernetes
CMD python ./service.py 0.0.0.0

FROM base as tester
ENV WORKER_MANAGER=kubernetes
CMD python setup.py test

FROM base as coverage_tester
FROM base as runner
ENV WORKER_MANAGER=kubernetes
ENV WITH_COVERAGE='True'
RUN apk add bash
COPY --from=builder /usr/local/bin/coverage /usr/local/bin/coverage
CMD python setup.py test
CMD python ./service.py 0.0.0.0 5000
3 changes: 1 addition & 2 deletions aimmo-game/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ verify_ssl = true
name = "pypi"

[packages]
aimmo-game = {path = ".", editable = true}
aimmo-game = {editable = true, path = "."}
docker = "*"
kubernetes = "*"
prometheus-client = "*"
aiohttp = "*"
aiohttp-cors = "*"
coverage = "*"

[requires]
python_version = "3.6.7"
Loading

0 comments on commit 54e2596

Please sign in to comment.