Skip to content

Commit

Permalink
Update Readme and Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenvanhuan243 committed Apr 3, 2024
1 parent 5d3fa71 commit 5d8341f
Show file tree
Hide file tree
Showing 75 changed files with 375 additions and 135,727 deletions.
2 changes: 2 additions & 0 deletions .env_localhost
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
API_BASE_URL=http://localhost:3001
SOCKET_BASE_URL=ws://localhost:3001/cable
25 changes: 22 additions & 3 deletions .github/workflows/deploy_server.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- master

jobs:
build:
build_and_deploy:
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -20,6 +20,7 @@ jobs:
- 14.x
steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand All @@ -29,8 +30,26 @@ jobs:

- run: npm install

- name: Build Docker Image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
run: |
docker build \
-t remi_frontend \
.
docker tag remi_frontend:latest nguyenvanhuan243/remi_frontend:latest
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker Image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
docker push nguyenvanhuan243/remi_frontend:latest
- name: Deploy to Render Server (Master)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
curl -X GET https://api.render.com/deploy/srv-co204qa1hbls73a4dt80?key=DnDmNBz6bEw
curl -X GET https://api.render.com/deploy/srv-co56ptkf7o1s739ab000?key=FBM5n-MMv5M
curl -X GET https://api.render.com/deploy/srv-co6f480l6cac73a7uii0?key=KFJgS6f3WC0
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use the official Node.js 14 image as base
FROM node:14

# Set the working directory in the container
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install dependencies
RUN npm -g uninstall node-sass && \
npm install node-sass@4.14.1 && \
npm install
# Copy the rest of the application code to the working directory
COPY . .

# Expose port 3000 to the outside world
EXPOSE 3000

# Command to run the production server
CMD ["npm", "start"]
9 changes: 3 additions & 6 deletions app/api/backend/movies.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import config from '../../../config';

const MovieAPI = {

// Get movies
getMovies: (title) => {
if (title) return axios.get(`${config.API_URL}/movies?title=${title}`);
return axios.get(`${config.API_URL}/movies`);
getMovies: () => {
return axios.get(`${config.API_BASE_URL}/api/v1/movies`);
},

// Create movies
create: (params, accessToken) => {
const requestUrl = `${config.API_URL}/movies`;
const requestUrl = `${config.API_BASE_URL}/api/v1/movies`;
const authOptions = {
headers: {
Authorization: accessToken,
Expand Down
17 changes: 3 additions & 14 deletions app/api/backend/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,19 @@ import config from '../../../config';
const UserAPI = {
// Create a user
create: params => {
const requestUrl = `${config.API_URL}/users`;
const requestUrl = `${config.API_BASE_URL}/api/v1//users`;
return axios.post(requestUrl, params);
},

// Login user
login: params => {
const requestUrl = `${config.API_URL}/users/sign_in`;
const requestUrl = `${config.API_BASE_URL}/api/v1/users/sign_in`;
return axios.post(requestUrl, params);
},

// Change Password Of User.
changePassword: (params, accessToken) => {
const requestUrl = `${config.API_URL}/users/change_password`;
const authOptions = {
headers: {
Authorization: accessToken,
},
};
return axios.post(requestUrl, params, authOptions);
},

// Get user by access token
getUserByAccessToken: accessToken => {
const requestUrl = `${config.API_URL}/users/me`;
const requestUrl = `${config.API_BASE_URL}/api/v1/users/me`;
const authOptions = {
headers: {
Authorization: accessToken,
Expand Down
6 changes: 3 additions & 3 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ if (!window.Intl) {
// Install ServiceWorker and AppCache in the end since
// it's not most important operation and if main code fails,
// we do not want it installed
if (process.env.NODE_ENV === 'production') {
require('offline-plugin/runtime').install(); // eslint-disable-line global-require
}
// if (process.env.NODE_ENV === 'production') {
// require('offline-plugin/runtime').install(); // eslint-disable-line global-require
// }
9 changes: 0 additions & 9 deletions app/assets/scss/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@
@import 'components/VideoCard/LoadingList/styles.scss';
@import 'containers/HomePage/styles.scss';
@import 'components/SearchNotFound/styles.scss';
@import 'components/LoginRegister/GeneralComponent/Form/styles.scss';
@import 'components/LoginRegister/SocialNetworkComponent/styles.scss';
@import 'components/LoginRegister/ChangePassword/styles.scss';
@import 'components/LoadingList/LoadingItem/styles.scss';
@import 'components/LoadingList/LoadingList/styles.scss';
@import 'components/Popup/Login/styles.scss';
@import 'components/Popup/ForgotPassword/styles.scss';
@import 'components/Popup/Signup/styles.scss';
@import 'components/MenuList/styles.scss';
@import 'components/Select/SingleSelect/styles.scss';
@import 'containers/ShareMovie/styles.scss';
@import 'containers/ChangePassword/styles.scss';
@import 'containers/Employee/List/styles.scss';
@import 'containers/PageTesting/styles.scss';



2 changes: 1 addition & 1 deletion app/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class Header extends PureComponent {
dispatch = action => this.setState(reducer(this.state, action));

shareMovie = () => {
if (UserUtils.getAccessToken()) return location.replace(`${location.origin}/share`);
if (UserUtils.getAccessToken()) return location.replace("/share");
Swal({
title: 'You not login',
text: 'You need to login to share movie',
Expand Down
29 changes: 3 additions & 26 deletions app/components/ImageAvatar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Avatar from '@material-ui/core/Avatar';
import { isEmpty } from 'lodash';
import axios from 'axios';
import config from '../../../config';

const styles = {
Expand All @@ -16,41 +14,20 @@ const styles = {
height: 40,
},
};
const requestUrl = `${config.API_URL}/users/${localStorage.currentUser}`;

class ImageAvatar extends PureComponent {
constructor() {
super();
this.state = {
user: {},
};
}

componentWillMount() {
axios.get(requestUrl).then(response => {
this.setState({ user: response.data });
});
}

getAvatarLink = user => {
if (isEmpty(user) || isEmpty(user.url_avatar)) {
return config.DEFAULT_AVATAR;
}
return user.url_avatar;
this.state = {};
}

render() {
const {
classes,
} = this.props;
const {
user,
} = this.state;
const { classes } = this.props;
return (
<div className={classes.row}>
<Avatar
alt="Remy Sharp"
src={this.getAvatarLink(user)}
src='https://i.ibb.co/NWrSrLR/Screen-Shot-2022-08-08-at-21-30-04.png'
className={classes.avatar}
/>
</div>
Expand Down
9 changes: 0 additions & 9 deletions app/components/LoginRegister/ChangePassword/Loadable.js

This file was deleted.

88 changes: 0 additions & 88 deletions app/components/LoginRegister/ChangePassword/index.js

This file was deleted.

Loading

0 comments on commit 5d8341f

Please sign in to comment.