Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update package.json #1

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node.js runtime as a parent image
FROM node:14

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

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

# Install application dependencies
RUN npm install

# Copy the rest of the application files to the container
COPY . .

# Expose port 3000 (assuming your Next.js app runs on port 3000)
EXPOSE 3000

# Define the command to run your application in development mode
CMD ["npm", "run", "dev"]
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,56 @@
## Hi there!
## Hi there! this my new project

The objective of this project was to learn how to use web sockets and how to create a multiplayer game. It was created using Next.js, React and Sockets.io. You can check it out [here](http://bingo-oandre.herokuapp.com/en) or [here](http://bingo-oandre.herokuapp.com/) for the Portuguese version. Feel free to modify as you wish.

The objective of this project was to learn how to use web sockets and how to create a multiplayer game. It was created using Next.js, React and Sockets.io. You can check it out for the English version. Feel free to modify as you wish.

If you want the logic of the game bingo, go to utils → bingo.js.



## Getting Started

Install node.js 16 version v16.20.2 combatiable with our application
npm 8.19.4 version
First, run the development server:

```bash
npm install
npm run dev
to run in background
nohup npm run dev &

```
Docker Container application

docker build -t imagename rootdir


docker build -t bingo .

docker run -p 3000:3000 -d --name bingo your-image-name



docker run -p 3000:3000 -d --name bingoapp bingo


# Build and start the Docker container
docker-compose up -d

To stop the containers, you can use the following command:
# Stop the Docker containers

docker-compose down

# Restart the Docker after permissions Granted

sudo usermod -aG docker ubuntu

sudo usermod -aG jenkins $USER

sudo systemctl restart docker

docker-compose build

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

Expand Down
2 changes: 1 addition & 1 deletion components/BingoWinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styles from "../styles/BingoWinner.module.css";
export default function BingoWinner(props) {
return (
<section className={styles.main}>
<p className={styles.title}>{props.winner} venceu!</p>
<p className={styles.title}>{props.winner} victory!</p>
</section>
);
}
6 changes: 3 additions & 3 deletions components/ChatDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default function ChatDisplay(props) {
case "cartela":
return (
<div key={idx_} className={styles.msg_received}>
<p className={styles.msg_received_p}>seus numeros são:</p>
<p className={styles.msg_received_p}>your numbers are:</p>
<p className={styles.msg_received_p}>{e_.msg.toString()}</p>
<p className={styles.msg_received_p}>boa sorte!</p>
<p className={styles.msg_received_p}>Good luck!</p>
</div>
);
case "sent-200":
Expand Down Expand Up @@ -81,7 +81,7 @@ export default function ChatDisplay(props) {
value={msg}
onChange={(e) => setMsg(e.target.value)}
onKeyDown={handleEnter}
placeholder="Digite sua mensagem..."
placeholder="Enter your message..."
></input>
<button className={styles.input_btn} onClick={sendMsg}>
<div className={styles.icon_box}>
Expand Down
2 changes: 1 addition & 1 deletion components/CreateHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function CreateHost(props) {
return (
<section className={styles.main}>
<Head>
<title>Bingo! - Criar Sala</title>
<title>Bingo! - Create Room</title>
</Head>
<JoinForm
type="host"
Expand Down
22 changes: 11 additions & 11 deletions components/JoinForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function JoinForm(props) {
case "room":
return (
<>
<label className={styles.label}>Seu nome</label>
<label className={styles.label}>Your Name</label>
<input
autoComplete="off"
className={styles.input}
Expand All @@ -26,14 +26,14 @@ export default function JoinForm(props) {
className={`${styles.btn_enter} ${styles.bgc_green}`}
onClick={() => props.btnFunction(props.room, name2)}
>
Entrar
Enter
</button>
</>
);
case "home":
return (
<>
<label className={styles.label}>Id da Sala</label>
<label className={styles.label}>Room ID</label>
<input
autoComplete="off"
className={styles.input}
Expand All @@ -42,7 +42,7 @@ export default function JoinForm(props) {
name="room"
type="text"
></input>
<label className={styles.label}>Seu nome</label>
<label className={styles.label}>Your Name</label>
<input
autoComplete="off"
className={styles.input}
Expand All @@ -55,21 +55,21 @@ export default function JoinForm(props) {
className={`${styles.btn_enter} ${styles.bgc_green}`}
onClick={() => props.btnFunction(room, name2, "join")}
>
Entrar
Enter
</button>
<span className={styles.division}> ............. </span>
<button
className={`${styles.btn_enter} ${styles.bgc_dark_blue}`}
onClick={() => props.btnFunction(room, name2, "create")}
>
Criar Sala
Create Room
</button>
</>
);
case "host":
return (
<>
<label className={styles.label}>Id da Sala</label>
<label className={styles.label}>Room ID</label>
<input
autoComplete="off"
className={styles.input}
Expand All @@ -78,8 +78,8 @@ export default function JoinForm(props) {
name="room"
type="text"
></input>
{props.roomAvailability && <p> sala ocupada </p>}
<label className={styles.label}>Quantidade de bolas</label>
{props.roomAvailability && <p> Room occupied </p>}
<label className={styles.label}>Number of Balls</label>
<input
className={styles.input}
value={qtdBalls}
Expand All @@ -89,7 +89,7 @@ export default function JoinForm(props) {
max={99}
type="number"
></input>
<label>Escolha opção: </label>
<label>Choose option: </label>
<select
name="cars"
id="cars"
Expand All @@ -102,7 +102,7 @@ export default function JoinForm(props) {
className={`${styles.btn_enter} ${styles.bgc_green}`}
onClick={() => props.btnFunction(room, qtdBalls, gameOption)}
>
Criar
Create
</button>
</>
);
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'

services:
nextjs-app:
container_name: nextjs-container
build:
context: .
ports:
- "3000:3000"
volumes:
- ./:/usr/src/app

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"eslint-config-next": "12.1.6"
},
"engines": {
"node": "16.13.0"
"node": "16.20.2"
}
}
1 change: 1 addition & 0 deletions testfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this for testing