Skip to content

Commit

Permalink
updated the docker-config
Browse files Browse the repository at this point in the history
  • Loading branch information
makakken committed Jan 30, 2023
1 parent 7ce7a32 commit 353b4b8
Show file tree
Hide file tree
Showing 7 changed files with 28,004 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ It's meant to be only for test purposes. The data can be reset at any time.
+ alternativly you can use the `script/pack.py`-script to build your own package and host it with an HTTP-server

### By using Docker for Development
* cd into `/roseguarden/frontend` Folder and run `docker run -it -v roseguard_node_modules:/usr/src/service/node_modules -v ${PWD}/package.json:/usr/src/service/package.json -w /usr/src/service node:16 npm install`
* cd back into `/roseguarden` and run docker-compose up
* run `docker-compose up -d`
* change frontend/nuxt.config.js change proxy-targets to: target: http://backend:5000 for /api/v1 and /api/v1/log
* frontend is now listening on localhost:3000, backend on localhost:5000
* frontend is listening on localhost:3000
* backend is listening on localhost:8002 (e.g. for direct calls via insomnia)

:boom: **Note:** the first command is caching an `npm install` into a named docker volume, which is then used in docker-compose. If you change anything in package.json rerun the first command to update dependencies.

Expand Down
3 changes: 3 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM python:3
ADD . /backend
WORKDIR /backend

ENV FLASK_ENV=development

RUN pip install -r requirements.txt
CMD flask run --host=0.0.0.0
2 changes: 2 additions & 0 deletions backend/core/logs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
__license__ = "GPLv3"

from core.logs import logs_bp, logManager
from flask_jwt_extended import jwt_required


@logs_bp.route('/api/v1/log', methods=["GET"])
@jwt_required
def log():
log_string = ""
for e in logManager.logQueue:
Expand Down
23 changes: 14 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ services:
backend:
build: ./backend
ports:
- "5000:5000"
- "8002:5000"
volumes:
- ./backend:/backend
frontend:
image: node:16
build: ./frontend
volumes:
- ./frontend:/usr/src/service/
- roseguard_node_modules:/usr/src/service/node_modules
working_dir: /usr/src/service
command: bash -c "npm run dev"
- ./frontend/api:/usr/src/nuxt-app/api
- ./frontend/assets:/usr/src/nuxt-app/assets
- ./frontend/components:/usr/src/nuxt-app/components
- ./frontend/layouts:/usr/src/nuxt-app/layouts
- ./frontend/middleware:/usr/src/nuxt-app/middleware
- ./frontend/pages:/usr/src/nuxt-app/pages
- ./frontend/plugins:/usr/src/nuxt-app/plugins
- ./frontend/static:/usr/src/nuxt-app/static
- ./frontend/store:/usr/src/nuxt-app/store
- ./frontend/util:/usr/src/nuxt-app/util
- ./frontend/package-lock.json:/usr/src/nuxt-app/package-lock.json
- ./frontend/package.json:/usr/src/nuxt-app/package.json
ports:
- "3000:3333"
volumes:
roseguard_node_modules:
external: true

22 changes: 22 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dockerfile
FROM node:16-alpine

# create destination directory
RUN mkdir -p /usr/src/nuxt-app
WORKDIR /usr/src/nuxt-app

# update and install dependency
RUN apk update && apk upgrade
RUN apk add git

# copy the app, note .dockerignore
COPY . /usr/src/nuxt-app/
RUN npm install
RUN npm run build

EXPOSE 3000

ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3000

CMD [ "npm", "run", "dev" ]
Loading

0 comments on commit 353b4b8

Please sign in to comment.