Skip to content
Closed
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
78 changes: 78 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: Docker

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

on: # yamllint disable-line rule:truthy
pull_request:
branches:
- main
- stable-*
tags:
- "*"

jobs:
build:
name: Build docker image
runs-on: ubuntu-latest
env:
image_name: "ansible-pattern-service-test"
image_tag: "${{ github.sha }}"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build the container image
run: make build
shell: bash
env:
CONTAINER_RUNTIME: docker
IMAGE_NAME: "${{ env.image_name }}"
IMAGE_TAG: "${{ env.image_tag }}"

- name: Run the container image
run: docker run -d -p "8000:5000" --name ansible-pattern-service-api "${IMAGE_NAME}:${IMAGE_TAG}"
shell: bash
env:
IMAGE_NAME: "${{ env.image_name }}"
IMAGE_TAG: "${{ env.image_tag }}"

- name: List running containers
run: docker ps -a
shell: bash

- name: Wait for the services to be up and running
run: sleep 15s
shell: bash

- name: Test the pattern service application
run: curl http://localhost:8000/ping/
shell: bash

compose:
name: Deploy the pattern service application with the dispatcher service
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: docker compose up
run: make compose-up
shell: bash
env:
CONTAINER_RUNTIME: docker
COMPOSE_UP_OPTS: "-d"

- name: Wait for the services to be up and running
run: sleep 15s
shell: bash

- name: List running services
run: docker ps -a
shell: bash

- name: Test the service are up and running
run: curl localhost:8000/api/pattern-service/v1/test/
shell: bash
12 changes: 5 additions & 7 deletions .github/workflows/units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements-dev.txt

- name: Run migrations
run: python manage.py migrate

- name: Run core tests
run: python manage.py test core
python -m pip install -U tox
shell: bash

- name: Run unit tests
run: tox -e unit_tests -vv
shell: bash
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ pre-commit-user
*.py[c,o]
/.eggs
.python-version

/.install
/.tests

# Testing
.cache
Expand Down
21 changes: 0 additions & 21 deletions Dockerfile.dev

This file was deleted.

57 changes: 50 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,56 @@
.PHONY: build build-multi run test clean install-deps lint push-quay login-quay push-quay-multi
.PHONY: build clean push compose-up compose-down compose-clean

# Image name and tag
CONTAINER_RUNTIME ?= podman
IMAGE_NAME ?= ansible-pattern-service
IMAGE_TAG ?= latest
COMPOSE_UP_OPTS ?=
COMPOSE_OPTS ?=


## docker compose targets
compose-build:
$(CONTAINER_RUNTIME) compose -f tools/docker/docker-compose.yaml $(COMPOSE_OPTS) build

compose-up:
$(CONTAINER_RUNTIME) compose -f tools/docker/docker-compose.yaml $(COMPOSE_OPTS) up $(COMPOSE_UP_OPTS) --remove-orphans

compose-down:
$(CONTAINER_RUNTIME) compose -f tools/docker/docker-compose.yaml $(COMPOSE_OPTS) down --remove-orphans

compose-clean:
$(CONTAINER_RUNTIME) compose -f tools/docker/docker-compose.yaml rm -sf
docker rmi --force localhost/ansible-pattern-service-api localhost/ansible-pattern-service-worker
docker volume rm -f postgres_data

compose-restart: compose-down compose-clean compose-up

## docker compose targets for macOS
compose-mac-build:
$(CONTAINER_RUNTIME) compose -f tools/docker/docker-compose-mac.yaml $(COMPOSE_OPTS) build

compose-mac-up:
$(CONTAINER_RUNTIME) compose -f tools/docker/docker-compose-mac.yaml $(COMPOSE_OPTS) up $(COMPOSE_UP_OPTS) --remove-orphans

compose-mac-down:
$(CONTAINER_RUNTIME) compose -f tools/docker/docker-compose-mac.yaml $(COMPOSE_OPTS) down --remove-orphans

compose-mac-clean:
$(CONTAINER_RUNTIME) compose -f tools/docker/docker-compose-mac.yaml rm -sf
docker rmi --force localhost/ansible-pattern-service-api localhost/ansible-pattern-service-worker
docker volume rm -f postgres_data

compose-mac-restart: compose-mac-down compose-mac-clean compose-mac-up


# Build the Docker image
build:
build_amd64:
@echo "Building container image..."
$(CONTAINER_RUNTIME) build -t $(IMAGE_NAME):$(IMAGE_TAG) -f Dockerfile.dev --arch amd64 .
$(CONTAINER_RUNTIME) build -t $(IMAGE_NAME):$(IMAGE_TAG) --target aap-dev-image -f tools/docker/Dockerfile --arch amd64 .

ensure-namespace:
ifndef QUAY_NAMESPACE
$(error QUAY_NAMESPACE is required to push quay.io)
endif
build:
@echo "Building container image..."
$(CONTAINER_RUNTIME) build -t $(IMAGE_NAME):$(IMAGE_TAG) --target aap-dev-image -f tools/docker/Dockerfile .

# Clean up
clean:
Expand All @@ -25,3 +62,9 @@ push: ensure-namespace build
@echo "Tagging and pushing to registry..."
$(CONTAINER_RUNTIME) tag $(IMAGE_NAME):$(IMAGE_TAG) quay.io/$(QUAY_NAMESPACE)/$(IMAGE_NAME):$(IMAGE_TAG)
$(CONTAINER_RUNTIME) push quay.io/$(QUAY_NAMESPACE)/$(IMAGE_NAME):$(IMAGE_TAG)

ensure-namespace:
ifndef QUAY_NAMESPACE
$(error QUAY_NAMESPACE is required to push quay.io)
endif

6 changes: 0 additions & 6 deletions core/apps.py

This file was deleted.

165 changes: 0 additions & 165 deletions core/migrations/0001_initial.py

This file was deleted.

Loading
Loading