This commit is contained in:
Eden Kirin
2024-01-11 12:11:37 +01:00
parent f09a149ee5
commit 7a458790d2
5 changed files with 286 additions and 95 deletions

5
api-server/.dockerignore Normal file
View File

@ -0,0 +1,5 @@
**/.env/
**/__pycache__/
**/Makefile
**/Dockerfile
*.log

View File

@ -6,14 +6,13 @@ ENV \
EXPOSE 3000
WORKDIR /app
COPY ./app .
RUN \
python -m venv /venv && \
pip install -r requirements.txt
WORKDIR /app
# start shell script when container starts
ENTRYPOINT ["/app/run.sh"]

View File

@ -4,6 +4,7 @@ CONTAINER_NAME=api-server
build: clean
@docker build \
--progress=plain \
--no-cache \
--tag $(IMAGE_NAME) \
.
@ -12,8 +13,19 @@ run:
--name $(IMAGE_NAME) \
--publish 3000:3000 \
--env CONTAINER_NAME="Awesome API server" \
--detach \
$(CONTAINER_NAME)
run-mount-log:
@docker run \
--name $(IMAGE_NAME) \
--publish 3000:3000 \
--volume /var/log/api-server:/app/log \
--env CONTAINER_NAME="Awesome API server" \
--detach \
$(CONTAINER_NAME)
clean:
- @docker stop $(CONTAINER_NAME)
- @docker rm $(CONTAINER_NAME)

View File

@ -18,7 +18,11 @@ async def root():
def main():
logging.basicConfig(filename=LOG_FILE, level=logging.INFO)
logging.basicConfig(
filename=LOG_FILE,
format="%(asctime)s %(levelname)s %(message)s",
level=logging.INFO,
)
logging.info(f"Starting server {CONTAINER_NAME}")