Skip to content

Commit

Permalink
feat(ci/cd): add ARG to build with web server
Browse files Browse the repository at this point in the history
  • Loading branch information
Khenziii committed May 26, 2024
1 parent 8715b68 commit 9995430
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
FROM python:3.11-alpine AS base

# set this arg to true, if you want
# to build the app with a speciffic
# port (8080) exposed.
ARG WEB_SERVER=false
ENV WEB_SERVER=$WEB_SERVER

WORKDIR /app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

CMD ["python3", "main.py"]
RUN if [ "$WEB_SERVER" = "false" ]; then \
rm docker-entrypoint.py; \
else \
pip3 install flask; \
fi

CMD if [ "$WEB_SERVER" = "false" ]; then \
exec python3 main.py; \
else \
exec python3 docker-entrypoint.py; \
fi

15 changes: 15 additions & 0 deletions docker-entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from flask import Flask, jsonify
import threading

app = Flask(__name__)

@app.route('/', methods=['GET'])
def index():
return jsonify({"status": "ok"}), 200

if __name__ == '__main__':
t = threading.Thread(target=lambda: app.run(host='0.0.0.0', port=8080))
t.start()

import main

0 comments on commit 9995430

Please sign in to comment.