-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci/cd): add ARG to build with web server
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
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
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 | ||
|
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 |
---|---|---|
@@ -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 | ||
|