Skip to content

Commit

Permalink
Merge pull request #9 from chrisbouchard/feature/build-image
Browse files Browse the repository at this point in the history
Start building a Docker App
  • Loading branch information
chrisbouchard authored Apr 4, 2020
2 parents 8536d8a + 7d45506 commit 7afe1bd
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 8 deletions.
84 changes: 77 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,56 @@ version: 2.1
orbs:
docker: circleci/docker@1.0.1

executors:
discord-fate-bot-build:
docker:
- image: chrisbouchard/discord-fate-bot-build:3.8

commands:
docker-app-build:
description: 'Build a Docker App bundle'
parameters:
app-name:
type: string
image:
type: string
tag:
type: string
steps:
- run: |
IFS="," read -ra DOCKER_TAGS \<<< "<<parameters.tag>>"
for tag in "${DOCKER_TAGS[@]}"
do
docker_tag_args="$docker_tag_args -t <<parameters.image>>:${tag}"
done
docker app bundle <<parameters.app-name>> $docker_tag_args
docker-app-push:
description: 'Push a Docker App bundle'
parameters:
app-name:
type: string
image:
type: string
tag:
type: string
steps:
- run: |
IFS="," read -ra DOCKER_TAGS \<<< "<<parameters.tag>>"
for tag in "${DOCKER_TAGS[@]}"
do
docker_tag_args="$docker_tag_args -t <<parameters.image>>:${tag}"
done
docker app push <<parameters.app-name>> $docker_tag_args
jobs:
test:
description: Verify that Unit Tests Pass
docker:
- image: chrisbouchard/python-poetry:3.7-1.0.5
executor: discord-fate-bot-build
steps:
- checkout
- run:
Expand All @@ -25,8 +70,7 @@ jobs:

build:
description: Build the Distribution
docker:
- image: chrisbouchard/python-poetry:3.7-1.0.5
executor: discord-fate-bot-build
steps:
- checkout
- run:
Expand All @@ -53,8 +97,7 @@ jobs:

publish-pypi:
description: Publish to PyPI
docker:
- image: chrisbouchard/python-poetry:3.7-1.0.5
executor: discord-fate-bot-build
steps:
- checkout
- attach_workspace:
Expand All @@ -66,7 +109,7 @@ jobs:
publish-docker-hub:
description: Publish to Docker Hub
executor: docker/docker
executor: discord-fate-bot-build
steps:
- checkout
- setup_remote_docker
Expand All @@ -80,6 +123,26 @@ jobs:
image: $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME
tag: $CIRCLE_SHA1,$CIRCLE_TAG,latest

publish-app-docker-hub:
description: Publish App to Docker Hub
executor: discord-fate-bot-build
steps:
- checkout
- setup_remote_docker
- docker/check
- run:
name: Docker App Bundle
command: |
docker app bundle --tag $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME-app:$CIRCLE_SHA1
- docker-app-build:
app-name: discord-fate-bot
image: $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME
tag: $CIRCLE_SHA1,$CIRCLE_TAG,latest
- docker-app-push:
app-name: discord-fate-bot
image: $DOCKER_LOGIN/$CIRCLE_PROJECT_REPONAME
tag: $CIRCLE_SHA1,$CIRCLE_TAG,latest

# Private map with some common job filter definitions.
.filters:
all-branches-and-tags: &all-branches-and-tags
Expand Down Expand Up @@ -127,3 +190,10 @@ workflows:
<<: *only-version-tags
context: discord-fate-bot/publish-docker-hub

- publish-app-docker-hub:
requires:
- publish-docker-hub
filters:
<<: *only-version-tags
context: discord-fate-bot/publish-docker-hub

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ freeze it once I release a stable public version.

## Installing

***This section is out-of-date since I've started bulding a Docker App.***
Please bear with me while I work out the bugs with that, and then I'll update
this section.

Discord Fate Bot is available [on Docker Hub][docker-dfb]. Images are
automatically built and published based on our `Dockerfile`. There is also a
`docker-compose.yml` file to deploy the app in Docker Swarm as a Stack,
Expand Down
19 changes: 19 additions & 0 deletions build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Base off the CircleCI Python image, which also has Docker installed
ARG PYTHON_VERSION=3.8
FROM circleci/python:${PYTHON_VERSION}-buster

ENV DOCKER_CLI_EXPERIMENTAL=enabled
ARG DOCKER_APP_VERSION=0.8.0

# Install Docker App
RUN export OSTYPE="$(uname | tr A-Z a-z)" && \
curl -fsSL --output "/tmp/docker-app-${OSTYPE}.tar.gz" \
"https://github.com/docker/app/releases/download/v${DOCKER_APP_VERSION}/docker-app-${OSTYPE}.tar.gz" && \
tar xf "/tmp/docker-app-${OSTYPE}.tar.gz" -C /tmp/ && \
mkdir -p ~/.docker/cli-plugins && \
cp "/tmp/docker-app-plugin-${OSTYPE}" ~/.docker/cli-plugins/docker-app

# Install Poetry
ARG POETRY_VERSION=1.0.5
RUN pip install --no-cache-dir poetry==${POETRY_VERSION}

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.6"

services:
app:
image: chrisbouchard/discord-fate-bot:latest
image: chrisbouchard/discord-fate-bot:${VERSION:-latest}
deploy:
restart_policy:
condition: on-failure
Expand Down
14 changes: 14 additions & 0 deletions discord-fate-bot.dockerapp/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Version of the application
version: $VERSION

# Name of the application
name: discord-fate-bot

# A short description of the application
description: Discord bot to help play the Fate role playing game

# List of application maintainers with name and email for each
maintainers:
- name: Chris Bouchard
email: chris@upliftinglemma.net

1 change: 1 addition & 0 deletions discord-fate-bot.dockerapp/parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 7afe1bd

Please sign in to comment.