Skip to content

Commit

Permalink
Added frontend and django services in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
andresGranadosC committed Sep 19, 2024
1 parent 41b84f3 commit ad71117
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 2 deletions.
24 changes: 24 additions & 0 deletions Dockerfile_django
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM python:3.10.13-bookworm

RUN mkdir /opt/scrapy

WORKDIR /opt/scrapy

RUN apt-get update && \
apt-get install -y wget && \
apt-get clean;

COPY gensitemap/requirements.txt requirements.txt
COPY gensitemap/scraper/ scraper/
COPY gensitemap/ui/ ui/
COPY gensitemap/frontend frontend/
#COPY gensitemap/ui/entrypoint_django.sh ui/entrypoint_django.sh
RUN pip3 install -r requirements.txt

# COPY generate-scrapyd.sh generate-scrapyd.sh
CMD [ "python3", "../ui/manage.py", "migrate", "--run-syncdb" ]
WORKDIR /opt/scrapy/ui
# WORKDIR /opt/scrapy/scraper
# SHELL ["/bin/bash", "-c"]
# RUN ../generate-scrapyd.sh
ENTRYPOINT ["/opt/scrapy/ui/entrypoint_django.sh"]
17 changes: 17 additions & 0 deletions Dockerfile_frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:20.17

RUN mkdir /opt/front

WORKDIR /opt/front

COPY gensitemap/frontend frontend
COPY entrypoint_frontend.sh frontend/entrypoint_frontend.sh

RUN echo "NODE Version:" && node --version
RUN echo "NPM Version:" && npm --version

WORKDIR /opt/front/frontend

RUN npm install

ENTRYPOINT ["/opt/front/frontend/entrypoint_frontend.sh"]
34 changes: 33 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,36 @@ services:
network: host
dockerfile: Dockerfile_sqlite
restart: "no"
entrypoint: [ "bash", "-c", "sqlite3" ]
entrypoint: [ "bash", "-c", "sqlite3" ]
frontend:
# expose:
# - "5173"
ports:
- "0.0.0.0:5173:5173"
networks:
- scrapy
build:
context: .
network: host
dockerfile: Dockerfile_frontend
restart: "no"
# entrypoint: [ "bash", "-c", "npm", "run", "dev" ]
django:
# volumes:
# - type: volume
# source: sqlitebd
# target: /opt/scrapy/ui
expose:
- "8000"
ports:
- "0.0.0.0:8000:8000"
networks:
- scrapy
build:
context: .
network: host
dockerfile: Dockerfile_django
restart: "no"
# entrypoint: [ "bash", "-c", "python", "manage.py", "runserver" ]
# healthcheck:
# test: [ "CMD", "./venv_scrapyd/bin/scrapyd-deploy", "default" ]
5 changes: 5 additions & 0 deletions entrypoint_frontend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

cd /opt/front/frontend || exit

npm run dev
2 changes: 1 addition & 1 deletion gensitemap/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
Expand Down
2 changes: 2 additions & 0 deletions gensitemap/ui/crawler_ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
DEBUG = True

ALLOWED_HOSTS = [
'0.0.0.0',
'0.0.0.0:8000',
'127.0.0.1',
'127.0.0.1:8000',
'localhost',
Expand Down
5 changes: 5 additions & 0 deletions gensitemap/ui/entrypoint_django.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

cd /opt/scrapy/ui || exit

python3 manage.py runserver 0.0.0.0:8000

0 comments on commit ad71117

Please sign in to comment.