Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
VAIBHAV7500 committed Apr 15, 2024
1 parent 8b47fb6 commit 03b41e9
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 244 deletions.
38 changes: 28 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
FROM node:16
FROM node:20-alpine as frontend-builder

RUN apk app update && apk upgrade && \
apk add --no-cache bash git openssh

WORKDIR /app
COPY . .
WORKDIR /app/backend
RUN npm ci
WORKDIR /app/frontend
RUN npm ci

COPY ./frontend/ .

RUN npm install --silent

RUN npm install react-scripts@3.4.1 -g --silent

RUN npm run build



FROM node:20-alpine

RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh

WORKDIR /app
RUN sh ./build.sh
WORKDIR /app/backend
EXPOSE 8080
CMD ["node", "app.js"]

COPY ./backend/ .
COPY --from=frontend-builder /app/build ./build

RUN npm ci

EXPOSE 4200
CMD ["node", "app.js"]
32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,32 @@
![Cover Page](./images/cover.png)
</p>

# Demo

URL: https://anime-web-app.herokuapp.com/
# Test Account

Email: test@test.com

Password: Hello@123

# [Screenshots](#screenshots)

# Installation

## Quick Demo

Requirements: Docker & Docker Compose

```
sh setup.sh && sh start.sh
```

# Development

## Requirements

* Yarn - Setup yarn from [here](https://classic.yarnpkg.com/en/docs/install/#windows-stable)

* Node - Setup Node from [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)

* Self Signed SSL - [here](https://zeropointdevelopment.com/how-to-get-https-working-in-windows-10-localhost-dev-environment/)

* Redis - [here](https://linuxize.com/post/how-to-install-and-configure-redis-on-ubuntu-18-04/)

## Backend:
* Install packages required.
Expand All @@ -37,19 +42,6 @@ Password: Hello@123
cd backend
npm install
```
* Check for MySQL
```
which mysqld
```
If it shows the path then continue otherwise install MySQL.
* Create a config folder and copy config files in that folder

* Create a certificate folder and copy the self signed certificate over there.

* Create Database
```
npm run db
```

* Crate a .env file and copy the required content.
* Start Server
Expand Down
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
10 changes: 4 additions & 6 deletions backend/.env_sample
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
ENV=dev
CORS_ORIGIN=http://localhost:3000
CORS_ORIGIN=http://0.0.0.0:3000
PORT=4200
BASE_URL=http://localhost:4200
BASE_URL=http://0.0.0.0:4200
UPLOAD_DIR="./public/videos"
HOST=localhost
NODE_ENV=dev
HOST=0.0.0.0
RAZORPAY_KEY_ID=optional
RAZORPAY_KEY_SECRET=optional
SENDGRID_KEY=optional
SESSION_KEY=_abcd
SESSION_SECRET=1234
DB_USER=root
DB_PASS=pwd
DB_HOST=localhost
DB_HOST=db
DB=animeApp
DB_PORT=3306
7 changes: 5 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
FROM node:16
FROM node:20-alpine

RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh

WORKDIR /app

COPY . .

RUN npm ci

EXPOSE 8080
EXPOSE 4200

CMD ["node", "app.js"]

2 changes: 1 addition & 1 deletion backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if(process.env.NODE_ENV === "production"){
}))
}else {
global.redis = redis.createClient({
host: 'localhost',
host: 'redis',
port: 6379,
});
global.redis.on('error', (err) => {
Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
"ws": "^7.5.9"
},
"engines": {
"node": "14.x"
"node": "20.x"
}
}
5 changes: 0 additions & 5 deletions build.sh

This file was deleted.

27 changes: 0 additions & 27 deletions deploy.sh

This file was deleted.

8 changes: 8 additions & 0 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.7"
services:
app:
build:
context: .
dockerfile: Dockerfile


16 changes: 14 additions & 2 deletions backend/docker-compose.yaml → docker-compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ services:
image: mysql:8.0
volumes:
- mysql_data:/var/lib/mysql
- ./animeApp.sql:/docker-entrypoint-initdb.d/dump.sql
- ./backend/animeApp.sql:/docker-entrypoint-initdb.d/dump.sql
healthcheck:
test: mysqladmin ping --user=$MYSQL_USER --password=$MYSQL_ROOT_PASSWORD
interval: 10s
timeout: 5s
retries: 100
environment:
MYSQL_DATABASE: animeApp
MYSQL_ROOT_PASSWORD: pwd
Expand All @@ -23,6 +28,13 @@ services:
PMA_PORT: 3306
ports:
- "8080:80"

app:
depends_on:
db:
condition: service_healthy
redis:
condition: service_started

volumes:
mysql_data: {}
mysql_data: {}
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.7"
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "4200:4200"
environment:
NODE_ENV: production
ENV: production

32 changes: 0 additions & 32 deletions docker-compose.yml

This file was deleted.

1 change: 1 addition & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
20 changes: 3 additions & 17 deletions frontend/.env_sample
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
REACT_APP_BASE_URL=http://192.168.2.7:4200/
REACT_APP_BASE_URL=http://localhost:4200/
REACT_APP_API_KEY=Kp4mJvZ7XDluaVsDkKIchQVIuYWIJo3l
REACT_APP_SERVER_URL=http://192.168.2.7:4200/
REACT_APP_WEBSOCKET_URL=ws://192.168.2.7:4200
REACT_APP_SERVER_URL=http://localhost:4200/
REACT_APP_WEBSOCKET_URL=ws://localhost:4200
REACT_PRIVATE_KEY=123
REACT_APP_TINY_API_KEY=l1ogtgyej2icbacskxgja5mh74iygkxad8bmprn8qz5k0s7k
REACT_APP_HCAPTCHA_SITE_KEY=10000000-ffff-ffff-ffff-000000000001
PORT=3000
PUBLIC_URL=https://dev.animei.tv/
INLINE_RUNTIME_CHUNK=false


REACT_APP_BASE_URL=http://animeistag.net/
REACT_APP_API_KEY=Kp4mJvZ7XDluaVsDkKIchQVIuYWIJo3l
REACT_APP_SERVER_URL=http://animeistag.net/
REACT_APP_WEBSOCKET_URL=ws://animeistag.net
REACT_PRIVATE_KEY=123
REACT_APP_TINY_API_KEY=l1ogtgyej2icbacskxgja5mh74iygkxad8bmprn8qz5k0s7k
REACT_APP_HCAPTCHA_SITE_KEY=5f9da22f-a8bc-482b-9a0f-a29f06ef875c
PORT=3000
PUBLIC_URL=http://animeistag.net/
INLINE_RUNTIME_CHUNK=false

16 changes: 6 additions & 10 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
FROM node:16
FROM node:20-alpine
WORKDIR /app
COPY . .
WORKDIR /app/backend
RUN npm install
WORKDIR /app/frontent
RUN npm install

WORKDIR /app
RUN sh ./build.sh
WORKDIR /app/backend
EXPOSE 8080
CMD ["node", "app.js"]
RUN npm install --silent
RUN npm install react-scripts@3.4.1 -g --silent

EXPOSE 3000
CMD ["npm", "start"]
6 changes: 0 additions & 6 deletions install-build.sh

This file was deleted.

1 change: 1 addition & 0 deletions local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker compose -f docker-compose.local.yaml -f docker-compose.override.yaml up -d
Loading

0 comments on commit 03b41e9

Please sign in to comment.