Skip to content

Commit

Permalink
Refactor into single lib
Browse files Browse the repository at this point in the history
  • Loading branch information
fivegrant committed Jul 21, 2023
1 parent 22c9191 commit 37e2bec
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 403 deletions.
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ LANG = en_US.utf-8
PYTHON = $(shell which python3 || which python)
DOCKER = $(shell which docker)
DOCKER_COMPOSE = $(shell which docker || echo "$(DOCKER) compose")
DOCKER_COMPOSE_YAML = docker/docker-compose.yaml
export LANG

# Initializes submodules and copies environment file sample to env file.
Expand All @@ -20,21 +21,26 @@ endif

# Turn project on
.PHONY:up
up:docker-compose.yaml
$(DOCKER_COMPOSE) compose up -d
up:docker/docker-compose.yaml
$(DOCKER_COMPOSE) compose --file $(DOCKER_COMPOSE_YAML) up -d

# Rebuild all containers and turn project on
.PHONY:up-rebuild
up-rebuild:docker-compose.yaml
$(DOCKER_COMPOSE) compose up --build -d
up-rebuild:$(DOCKER_COMPOSE_YAML)
$(DOCKER_COMPOSE) compose --file $(DOCKER_COMPOSE_YAML) up --build -d

# Rebuild the docker image from scratch
.PHONY:up-rebuild
force-rebuild:$(DOCKER_COMPOSE_YAML)
$(DOCKER_COMPOSE) compose --file $(DOCKER_COMPOSE_YAML) build --no-cache

# Turn project off
.PHONY:down
down:docker-compose.yaml
$(DOCKER_COMPOSE) compose down
down:$(DOCKER_COMPOSE_YAML)
$(DOCKER_COMPOSE) compose --file $(DOCKER_COMPOSE_YAML) down

# Restart project
.PHONY:restart
restart:docker-compose.yaml
restart:$(DOCKER_COMPOSE_YAML)
make down && make up

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[![Build and Publish](https://github.com/DARPA-ASKEM/service-template/actions/workflows/publish.yaml/badge.svg?event=push)](https://github.com/DARPA-ASKEM/service-template/actions/workflows/publish.yaml)

# PyCIEMSS Simulation API
# PyCIEMSS Simulation Service

## Startup

Expand Down
15 changes: 0 additions & 15 deletions api/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions workers/Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ RUN pip install --no-cache-dir poetry==1.5.1
COPY pyproject.toml pyproject.toml
COPY poetry.lock poetry.lock
RUN poetry config virtualenvs.create false && \
poetry install --no-root --no-cache --extras worker
poetry install --no-root --no-cache

RUN pip install --no-cache-dir git+https://github.com/ciemss/pyciemss.git
COPY workers workers
COPY service service
COPY README.md README.md

ENV REDIS_HOST redis
Expand Down
24 changes: 7 additions & 17 deletions docker-bake.hcl → docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ function "check_suffix" {
# ----------------------------------------------------------------------------------------------------------------------

group "prod" {
targets = ["pyciemss-api", "pyciemss-worker"]
targets = ["pyciemss-service"]
}

group "default" {
targets = ["pyciemss-api-base", "pyciemss-worker-base"]
targets = ["pyciemss-service-base"]
}

# ----------------------------------------------------------------------------------------------------------------------
Expand All @@ -41,22 +41,12 @@ target "_platforms" {
platforms = ["linux/amd64", "linux/arm64"]
}

target "pyciemss-api-base" {
context = "."
tags = tag("pyciemss-api", "", "")
dockerfile = "api/Dockerfile"
target "pyciemss-service-base" {
context = ".."
tags = tag("pyciemss-service", "", "")
dockerfile = "docker/Dockerfile"
}

target "pyciemss-api" {
target "pyciemss-service" {
inherits = ["_platforms", "pyciemss-api-base"]
}

target "pyciemss-worker-base" {
context = "."
tags = tag("pyciemss-worker", "", "")
dockerfile = "workers/Dockerfile"
}

target "pyciemss-worker" {
inherits = ["_platforms", "pyciemss-worker-base"]
}
18 changes: 7 additions & 11 deletions docker-compose.yaml → docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ networks:
pyciemss:
driver: bridge
name: pyciemss
data-api:
#TODO Remove in production
external: true
services:
api:
container_name: pyciemss-api
build:
context: ./
dockerfile: api/Dockerfile
context: ..
dockerfile: docker/Dockerfile
command: uvicorn service.server:app --reload --host 0.0.0.0 --port 8000
ports:
- "8010:8000"
env_file:
- api.env
- ../api.env
networks:
- pyciemss
- data-api # TODO Remove in production
depends_on:
- redis
volumes:
Expand All @@ -35,12 +32,11 @@ services:
rqworker:
container_name: pyciemss-worker
build:
context: ./
dockerfile: workers/Dockerfile
context: ..
dockerfile: docker/Dockerfile
env_file:
- api.env
- ../api.env
depends_on:
- redis
networks:
- pyciemss
- data-api
Loading

0 comments on commit 37e2bec

Please sign in to comment.