-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from jecklgamis/next
Use Ubuntu 24.04
- Loading branch information
Showing
14 changed files
with
89 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
FROM ubuntu:22.04 | ||
FROM ubuntu:24.04 | ||
MAINTAINER Jerrico Gamis <[email protected]> | ||
|
||
RUN apt update -y && apt install -y curl dumb-init python3 python3-pip && rm -rf /var/lib/apt/lists/* | ||
RUN pip3 install --upgrade pip | ||
RUN apt update -y && apt install -y curl dumb-init python3 python3-venv python3-pip && rm -rf /var/lib/apt/lists/* | ||
RUN python3 -m venv /python3env | ||
|
||
COPY requirements.txt / | ||
RUN pip3 install --trusted-host pypi.python.org -r /requirements.txt | ||
RUN /python3env/bin/pip3 install --trusted-host pypi.python.org -r /requirements.txt | ||
|
||
ENV APP_HOME /app | ||
|
||
COPY app/* ${APP_HOME}/app/ | ||
COPY server_info.json ${APP_HOME} | ||
|
||
COPY server.crt ${APP_HOME} | ||
COPY server.key ${APP_HOME} | ||
COPY app/* $APP_HOME/app/ | ||
COPY build-info.json $APP_HOME | ||
COPY server.crt $APP_HOME | ||
COPY server.key $APP_HOME | ||
|
||
EXPOSE 8080 | ||
EXPOSE 8443 | ||
|
||
WORKDIR ${APP_HOME} | ||
WORKDIR $APP_HOME | ||
|
||
COPY docker-entrypoint.sh / | ||
RUN chmod +x /docker-entrypoint.sh | ||
|
||
ENTRYPOINT ["/usr/bin/dumb-init", "--"] | ||
CMD ["/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
IMAGE_NAME:=jecklgamis/flask-app-example | ||
IMAGE_TAG:=main | ||
IMAGE_NAME:=flask-app-example | ||
IMAGE_TAG:=$(shell git rev-parse --abbrev-ref HEAD) | ||
|
||
default: | ||
echo $(IMAGE_TAG) | ||
cat ./Makefile | ||
dist: | ||
@cat ./Makefile | ||
install-deps: | ||
@pip3 install -r requirements.txt | ||
build: | ||
@./generate-ssl-certs.sh | ||
@./generate-server-info.sh | ||
@./generate-build-info.sh | ||
image: | ||
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) . | ||
run-shell: | ||
@docker run -i -t $(IMAGE_NAME):$(IMAGE_TAG) /bin/bash | ||
run: | ||
@docker run -p 8443:8443 -p 8080:8080 -it $(IMAGE_NAME):$(IMAGE_TAG) | ||
|
||
all : dist tests image | ||
@docker run -p 8080:8080 -p 8443:8443 -it $(IMAGE_NAME):$(IMAGE_TAG) | ||
run-shell: | ||
@docker run -it $(IMAGE_NAME):$(IMAGE_TAG) /bin/bash | ||
exec-shell: | ||
docker exec -it `docker ps | grep $(IMAGE_NAME) | awk '{print $$1}'` /bin/bash | ||
all: build check image | ||
up: all run | ||
|
||
install-deps: | ||
@pip3 install -r requirements.txt | ||
@pip3 install -r requirements-dev.txt | ||
run-app-dev-mode: | ||
@./run-app-dev-mode.sh | ||
run-app-dev-mode-ssl: | ||
@./run-app-dev-mode.sh ssl | ||
smoke-tests: | ||
run-smoke-tests: | ||
@./smoke-tests.py | ||
.PHONY: tests | ||
tests: | ||
pytest -s | ||
check: | ||
@pytest -s | ||
clean: | ||
@find . -name build-info.json | xargs rm -f | ||
@find . -name server.key | xargs rm -f | ||
@find . -name server.crt | xargs rm -f | ||
@find . -name *.log| xargs rm -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
#!/usr/bin/env bash | ||
# exec gunicorn --bind 0.0.0.0:8443 --certfile server.crt --keyfile server.key 'app:create_app()' | ||
exec gunicorn --bind 0.0.0.0:8080 'app:create_app()' | ||
source /python3env/bin/activate | ||
|
||
if [ "$USE_SSL" = "true" ]; then | ||
exec gunicorn --bind 0.0.0.0:8443 --certfile server.crt --keyfile server.key 'app:app' | ||
else | ||
exec gunicorn --bind 0.0.0.0:8080 'app:app' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
COMMIT_ID=$(git rev-parse HEAD) | ||
echo "{ \"version\":\"${COMMIT_ID}\", \"branch\":\"${BRANCH}\", \"name\":\"flask-app-example\"}" > server_info.json | ||
echo "Wrote server_info.json" | ||
echo "{ \"version\":\"${COMMIT_ID}\", \"branch\":\"${BRANCH}\", \"name\":\"flask-app-example\"}" > build-info.json | ||
echo "Wrote build-info.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Flask==3.0.0 | ||
gunicorn==21.2.0 | ||
requests==2.31.0 | ||
Flask==3.0.3 | ||
gunicorn==22.0.0 | ||
requests==2.32.3 | ||
pytest==8.2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import logging as log | ||
import sys | ||
import unittest | ||
|
||
import requests | ||
import urllib3 | ||
|
||
|
||
class SmokeTests(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
SmokeTests.init() | ||
|
||
def testEndPointsExist(self): | ||
log.info("Ensuring endpoints exist") | ||
self.assertEqual(SmokeTests.get("https://localhost:8443/").status_code, 200) | ||
self.assertEqual(SmokeTests.get("https://localhost:8443/server_info").status_code, 200) | ||
self.assertEqual(SmokeTests.get("https://localhost:8443/api").status_code, 200) | ||
|
||
@staticmethod | ||
def get(url): | ||
return requests.get(url, verify=False) | ||
|
||
@staticmethod | ||
def init(): | ||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||
stdout_handler = log.StreamHandler(sys.stdout) | ||
log.basicConfig(level=log.INFO, | ||
format='[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s', | ||
handlers=[stdout_handler]) | ||
def test_endpoint_exists(): | ||
assert requests.get("http://localhost:8080/").status_code == 200 | ||
assert requests.get("http://localhost:8080/build-info").status_code == 200 | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
try: | ||
test_endpoint_exists() | ||
print("OK") | ||
except: | ||
print("NG") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters