diff --git a/.github/workflows/dockerbuild.yaml b/.github/workflows/dockerbuild.yaml new file mode 100644 index 0000000..3363fc5 --- /dev/null +++ b/.github/workflows/dockerbuild.yaml @@ -0,0 +1,43 @@ +name: Workflow to execute the full app using Docker Compose + +on: + push: + branches: + - main + - docker/docker + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Trivy + run: | + wget https://github.com/aquasecurity/trivy/releases/download/v0.18.3/trivy_0.18.3_Linux-64bit.deb + sudo dpkg -i trivy_0.18.3_Linux-64bit.deb + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Build Frontend Image + run: | + cd frontend + docker build -t "frontend:$GITHUB_RUN_NUMBER" . + + - name: Build Backend Image + run: | + cd backend + docker build -t "backend:$GITHUB_RUN_NUMBER" . + + + - name: Scanning Docker Images for Vulnerabilities + run: | + trivy image "frontend:$GITHUB_RUN_NUMBER" + trivy image "backend:$GITHUB_RUN_NUMBER" + + diff --git a/.github/workflows/dockerrun.yaml b/.github/workflows/dockerrun.yaml new file mode 100644 index 0000000..a024795 --- /dev/null +++ b/.github/workflows/dockerrun.yaml @@ -0,0 +1,20 @@ +name: Workflow to execute the full app using Docker Compose + +on: + push: + branches: + - main + - docker/docker + +jobs: + docker-compose: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build and run Fronted & Backend using Docker + run: | + docker-compose up -d + diff --git a/.gitignore b/.gitignore index 12e1ca9..142ef92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .aider* +.env # Run logs backend/run_logs/* + diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..2b73ce9 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.11 +MAINTAINER label="Rohan Rustagi" +WORKDIR /app/backend +COPY . . +EXPOSE 7000 +ENV OPENAI_API_KEY +RUN pip install poetry && \ + poetry install +CMD ["poetry", "run", "uvicorn", "main:app", "--reload", "--port", "7000"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d9be932 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,14 @@ +version: '3' +services: + frontend: + build: + context: ./frontend + ports: + - "5173:5173" + backend: + build: + context: ./backend + ports: + - "7000:7000" + env_file: + - backend/.env diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..d09d502 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,8 @@ +FROM node:16 +MAINTAINER label="Rohan Rustagi" +WORKDIR /usr/src/app +COPY package.json yarn.lock ./ +RUN yarn +COPY . . +EXPOSE 5173 +CMD ["yarn", "dev"] diff --git a/frontend/package.json b/frontend/package.json index 7a34ab2..0cb26af 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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"