💚 update docker

docker-deployment
Vincent ASTOLFI 9 months ago
parent 1d3aa1a3fe
commit 5678950806

@ -1,8 +1,16 @@
FROM node:16 FROM node:14
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
COPY . . COPY . .
#RUN sed -i '1i\<base href="https://codefirst.iut.uca.fr/containers/vincentastolfi-maettleship/">' ./public/index.html #RUN sed -i '1i\<base href="https://codefirst.iut.uca.fr/containers/vincentastolfi-maettleship/">' ./public/index.html
EXPOSE 8080
CMD ["npm", "run", "start"] EXPOSE 3000
ENV DB_HOST=db
ENV DB_USER=root
ENV DB_PASSWORD=password
ENV DB_NAME=battleship
CMD ["npm", "run", "prod"]

@ -1,30 +1,26 @@
version: '3'
services: services:
app: app:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "8080:8080" - "3000:3000"
volumes: volumes:
- .:/usr/src/app - .:/usr/src/app
- /usr/src/app/node_modules - /usr/src/app/node_modules
environment: environment:
- NODE_ENV=production
- DB_HOST=db - DB_HOST=db
- DB_USER=root - DB_USER=root
- DB_PASSWORD=password - DB_PASSWORD=password
- DB_NAME=myapp - DB_NAME=battleship
depends_on: depends_on:
- db - db
db: db:
platform: linux/x86_64 image: mysql:8.0
image: mysql:5.7
restart: always restart: always
environment: environment:
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: myapp
ports: ports:
- "3306:3306" - "3306:3306"
volumes: volumes:

@ -2,7 +2,7 @@ const express = require("express");
const app = express(); const app = express();
const http = require("http").Server(app); const http = require("http").Server(app);
const io = require("socket.io")(http); const io = require("socket.io")(http);
const port = 8080; const port = 3000;
const db = require("./database.js") const db = require("./database.js")
const jwt = require('jsonwebtoken'); const jwt = require('jsonwebtoken');
const cookieParser = require('cookie-parser'); const cookieParser = require('cookie-parser');

@ -4,6 +4,7 @@
"description": "Simple online battleship game that I design for mae when lectures are boring", "description": "Simple online battleship game that I design for mae when lectures are boring",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"prod": "node index.js",
"dev": "nodemon --env-file=.env index.js", "dev": "nodemon --env-file=.env index.js",
"start": "node --env-file=.env index.js" "start": "node --env-file=.env index.js"
}, },

Loading…
Cancel
Save