Skip to content

Commit

Permalink
Setup docker and docker compose for both services.
Browse files Browse the repository at this point in the history
  • Loading branch information
toukay committed Aug 19, 2024
1 parent 7ee48e1 commit 1a5309d
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
product-api:
build:
context: ./src/product_api
dockerfile: Dockerfile
container_name: product-api
volumes:
- ./src/product_api:/usr/src/app
- ./src/product_api/src/eshop.db:/usr/src/app/src/eshop.db
ports:
- "8000:8000"
environment:
- DEBUG=True
command: uvicorn src.app:app --host 0.0.0.0 --port 8000 --reload

web:
build:
context: ./src/web
dockerfile: Dockerfile
container_name: angular-web
volumes:
- ./src/web:/usr/src/app
- /usr/src/app/node_modules
ports:
- "4200:4200"
depends_on:
- product-api
command: ng serve --host 0.0.0.0 --port 4200

volumes:
sqlite_data:
21 changes: 21 additions & 0 deletions src/product_api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.12.4-alpine

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /usr/src/app

RUN apk update && \
apk add --no-cache --virtual .build-deps \
gcc python3-dev musl-dev ca-certificates libffi-dev

COPY requirements.txt ./

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

COPY . .

EXPOSE 8000

CMD ["uvicorn", "src.app:app", "--host", "0.0.0.0", "--port", "8000"]
Binary file removed src/product_api/eshop.db
Binary file not shown.
Binary file modified src/product_api/src/eshop.db
Binary file not shown.
15 changes: 15 additions & 0 deletions src/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:18-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

RUN npm install -g @angular/cli

COPY . .

EXPOSE 4200

CMD ["ng", "serve", "--host", "0.0.0.0"]

0 comments on commit 1a5309d

Please sign in to comment.