Skip to content

Commit

Permalink
chore: add a push to DockerHub
Browse files Browse the repository at this point in the history
  • Loading branch information
lpm0073 committed Jan 9, 2024
1 parent 6bcf852 commit 6d85eb7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
35 changes: 26 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

SHELL := /bin/bash
CONTAINER_NAME := hello_world
REPO_NAME := openai-hello-world
#TAGNAME := $(date +%Y%m%d%H%M)
TAGNAME := "test"

ifeq ($(OS),Windows_NT)
PYTHON = python.exe
Expand All @@ -13,7 +16,7 @@ PIP = $(PYTHON) -m pip
ifneq ("$(wildcard .env)","")
include .env
else
$(shell echo -e "OPENAI_API_KEY=PLEASE-ADD-ME\nENVIRONMENT=dev\n" >> .env)
$(shell echo -e "OPENAI_API_KEY=SET-ME-PLEASE\nENVIRONMENT=dev\nDOCKERHUB_USERNAME=localhost\nDOCKERHUB_ACCESS_TOKEN=SET-ME-PLEASE\n" >> .env)
endif

.PHONY: analyze pre-commit init lint clean test build release
Expand Down Expand Up @@ -55,7 +58,7 @@ init-dev:
make init
$(ACTIVATE_VENV) && \
$(PIP) install -r requirements/dev.txt && \
deactivate && \
deactivate

test:
python -m unittest discover -s app/
Expand All @@ -70,10 +73,20 @@ lint:
clean:
rm -rf venv node_modules app/__pycache__ package-lock.json

build:
docker build -t ${CONTAINER_NAME} .
docker-build:
source .env && \
docker build -t ${DOCKERHUB_USERNAME}/${REPO_NAME} .

run:
docker-push:
source .env && \
echo DOCKERHUB_USERNAME is ${DOCKERHUB_USERNAME} && \
echo DOCKERHUB_ACCESS_TOKEN is ${DOCKERHUB_ACCESS_TOKEN} && \
echo tagname is ${TAGNAME} && \
docker tag ${DOCKERHUB_USERNAME}/${REPO_NAME} ${DOCKERHUB_USERNAME}/${REPO_NAME}:${TAGNAME} && \
echo "${DOCKERHUB_ACCESS_TOKEN}" | docker login --username=${DOCKERHUB_USERNAME} --password-stdin && \
docker push ${DOCKERHUB_USERNAME}/${REPO_NAME}:${TAGNAME}

docker-run:
source .env && \
docker run -it -e OPENAI_API_KEY=${OPENAI_API_KEY} -e ENVIRONMENT=prod ${CONTAINER_NAME}

Expand All @@ -84,9 +97,13 @@ run:

help:
@echo '===================================================================='
@echo 'analyze - generate code analysis report'
@echo 'release - force a new release'
@echo 'init - create a Python virtual environment and install dependencies'
@echo 'analyze - generate code analysis report'
@echo 'release - force a new GitHub release'
@echo 'init - create a Python virtual environment and install prod dependencies'
@echo 'init-dev - install dev dependencies'
@echo 'test - run Python unit tests'
@echo 'lint - run Python linting'
@echo 'clean - destroy the Python virtual environment'
@echo 'docker-build - build the Docker image'
@echo 'docker-push - push the Docker image to DockerHub'
@echo 'docker-run - run the Docker image'
2 changes: 1 addition & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
]

# application configuration validations
if OPENAI_API_KEY in (None, "PLEASE-ADD-ME"):
if OPENAI_API_KEY in (None, "SET-ME-PLEASE"):
raise ConfigurationException("No OpenAI API key found. Please add it to your .env file.")

0 comments on commit 6d85eb7

Please sign in to comment.