Skip to content

Commit

Permalink
feat(devops): dockerize the whole application (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meminseeker authored Apr 28, 2024
1 parent 6a6ec02 commit 4de27f4
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 342 deletions.
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# base image
FROM python:3.12-slim-bullseye
# setup environment variable
ENV DockerHOME=/home/app/webapp
ENV DockerHOME=/home/app/backend

# set work directory
RUN mkdir -p $DockerHOME
Expand Down
18 changes: 0 additions & 18 deletions backend/docker-compose.yml

This file was deleted.

49 changes: 49 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# version is deprecated after docker 25.X
# version: '3.7'


services:
db:
image: mysql:8.0
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: mydatabase
MYSQL_USER: user
MYSQL_PASSWORD: password

backend:
build:
context: ./backend
ports:
- "8000:8000"
volumes:
- ./backend:/home/app/backend
command: >
sh -c "python manage.py makemigrations &&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000"
env_file: ./backend/.env
restart: "on-failure"
depends_on:
- db

web:
build:
context: ./web
ports:
- "5173:5173"
volumes:
- ./web:/home/app/web
command: >
sh -c "npm install &&
npm run build &&
serve -s dist -l 5173"
restart: "on-failure"
depends_on:
- backend

volumes:
db_data:
18 changes: 18 additions & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:18.20-bullseye-slim

ENV DockerHOME=/home/app/web

WORKDIR ${DockerHOME}

COPY package.json package-lock.json ./
RUN npm install

COPY . ${DockerHOME}

RUN npm run build

RUN npm install -g serve

EXPOSE 5173

CMD [ "serve", "-s", "build", "-l", "5173"]
Loading

0 comments on commit 4de27f4

Please sign in to comment.