diff options
author | 2019-09-19 22:46:24 +1000 | |
---|---|---|
committer | 2019-09-19 22:46:24 +1000 | |
commit | 9c23b4ae59449bacddbbf898e30850c691916803 (patch) | |
tree | 9d0a201d11ed4ad1af4fd396e610494018769f04 | |
parent | Merge pull request #270 from python-discord/flake8-annotations (diff) |
Cleanup Dockerfile and CI Build & Push stage
-rw-r--r-- | Dockerfile | 20 | ||||
-rw-r--r-- | azure-pipelines.yml | 15 | ||||
-rw-r--r-- | docker-compose.yml | 24 | ||||
-rw-r--r-- | docker/Dockerfile | 26 | ||||
-rw-r--r-- | docker/docker-compose.yml | 12 | ||||
-rwxr-xr-x | scripts/deploy-azure.sh | 14 |
6 files changed, 53 insertions, 58 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..214398c8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM bitnami/python:3.7-prod + +ENV PIP_NO_CACHE_DIR=false \ + PIPENV_HIDE_EMOJIS=1 \ + PIPENV_IGNORE_VIRTUALENVS=1 \ + PIPENV_NOSPIN=1 + +WORKDIR /bot +COPY . . + +# Update setuptools by removing egg first, add other dependencies +RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \ + pip install --no-cache-dir -U setuptools pipenv +RUN pipenv install --deploy --system + +ENTRYPOINT ["python"] +CMD ["-m", "bot"] + +VOLUME /bot/bot/log +VOLUME /bot/data diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c98bc4fc..e73980f8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -33,20 +33,23 @@ jobs: displayName: 'Run linter' - job: build - displayName: 'Build Containers' + displayName: 'Build & Push Container' + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) dependsOn: 'test' steps: - - task: Docker@1 - displayName: 'Login: Docker Hub' + - task: Docker@2 + displayName: 'Login to Docker Hub' inputs: containerregistrytype: 'Container Registry' dockerRegistryEndpoint: 'DockerHub' command: 'login' - - task: ShellScript@2 - displayName: 'Build and deploy containers' + - task: Docker@2 + displayName: 'Build & Push' inputs: - scriptPath: scripts/deploy-azure.sh + command: buildAndPush + repository: pythondiscord/seasonalbot + tags: latest diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f2f4b056 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: "3.7" +services: + seasonalbot: + build: + context: . + dockerfile: Dockerfile + container_name: seasonalbot + init: true + + restart: always + + environment: + - SEASONALBOT_TOKEN=yourtokenhere + - SEASONALBOT_DEBUG=true + # - SEASONALBOT_GUILD= + # - SEASONALBOT_ADMIN_ROLE_ID= + # - CHANNEL_ANNOUNCEMENTS= + # - CHANNEL_DEVLOG= + # - CHANNEL_SEASONALBOT_CHAT= + # - SEASON_OVERRIDE= + + volumes: + - /opt/pythondiscord/seasonalbot/log:/bot/bot/log + - /opt/pythondiscord/seasonalbot/data:/bot/data diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 67767ced..00000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM python:3.7.2-alpine3.9 - -ENTRYPOINT ["python"] -CMD ["-m", "bot"] - -ENV PIP_NO_CACHE_DIR="false" \ - PIPENV_DONT_USE_PYENV="1" \ - PIPENV_HIDE_EMOJIS="1" \ - PIPENV_IGNORE_VIRTUALENVS="1" \ - PIPENV_NOSPIN="1" - -RUN apk add --no-cache --update \ - build-base \ - git \ - libffi-dev \ - libwebp-dev \ - # Pillow dependencies - freetype-dev \ - libjpeg-turbo-dev \ - zlib-dev -RUN pip install pipenv - -COPY . /bot -WORKDIR /bot - -RUN pipenv install --deploy --system diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index 6e274451..00000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: "3.7" -services: - dumbo: - image: pythondiscord/seasonalbot:latest - container_name: seasonalbot - init: true - - restart: always - - environment: - - SEASONALBOT_TOKEN - diff --git a/scripts/deploy-azure.sh b/scripts/deploy-azure.sh deleted file mode 100755 index ad7bfb26..00000000 --- a/scripts/deploy-azure.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -cd .. - -# Build and deploy on master branch, only if not a pull request -if [[ ($BUILD_SOURCEBRANCHNAME == 'master') && ($SYSTEM_PULLREQUEST_PULLREQUESTID == '') ]]; then - echo "Building image" - docker build -t pythondiscord/seasonalbot:latest -f docker/Dockerfile . - - echo "Pushing image to Docker Hub" - docker push pythondiscord/seasonalbot:latest -else - echo "Skipping deploy" -fi |