Skip to content

Commit

Permalink
Clean up and relative url for socket
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Barkmin committed Sep 19, 2019
1 parent d1d2abc commit d59199f
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 84 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
backup

2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,7 +1,7 @@
FROM node:12 as client
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
ENV REACT_APP_SERVER wss://baby.barkmin.eu
ENV REACT_APP_SERVER /
COPY client/package.json /usr/src/app/package.json
RUN npm install --silent
RUN npm install react-scripts@3.0.1 -g --silent
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -48,6 +48,10 @@ You will have many little entries - trust me ;)

`docker-compose up`

# Deploy

`docker-compose -f docker-compose.prod.yml up`

## License

Licensed under the MIT License, Copyright © 2019-present Mike Barkmin.
Expand Down
1 change: 0 additions & 1 deletion client/.dockerignore

This file was deleted.

17 changes: 0 additions & 17 deletions client/Dockerfile.prod

This file was deleted.

17 changes: 0 additions & 17 deletions client/nginx/nginx.conf

This file was deleted.

4 changes: 3 additions & 1 deletion client/package.json
@@ -1,7 +1,9 @@
{
"name": "baby-tracker",
"version": "1.3.0",
"version": "1.3.1",
"private": true,
"author": "Mike Barkmin",
"license": "MIT",
"dependencies": {
"axios": "0.19.0",
"date-fns": "2.1.0",
Expand Down
15 changes: 7 additions & 8 deletions client/src/App.js
Expand Up @@ -52,18 +52,17 @@ const links = [
];

function BabyJoin() {
const [baby] = useLocalStorage('baby', null);
const [baby, setBaby] = useLocalStorage('baby', null);
const socket = useSocket();
socket.on('reconnect', () => {
if (baby !== null) {
socket.emit('baby/join', baby.shortId, d => {});
}
});
useEffect(() => {
if (baby !== null) {
socket.emit('baby/join', baby.shortId, d => {});
socket.emit('baby/join', baby.shortId, d => {
if (d.msg === 'baby not found') {
setBaby(null);
}
});
}
}, [baby, socket]);
}, [baby, setBaby, socket]);

return null;
}
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.prod.yml
@@ -0,0 +1,19 @@
version: '3'

services:
mongo:
image: mongo:4.2
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_DATABASE: baby-tracker
volumes:
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro

server:
image: mikebarkmin/baby-tracker:1.3.1
environment:
DATABASE_URL: mongodb://server:test@mongo:27017/baby-tracker

ports:
- 8080:8080
30 changes: 29 additions & 1 deletion docker-compose.yml
Expand Up @@ -9,11 +9,39 @@ services:
MONGO_INITDB_DATABASE: baby-tracker
volumes:
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
ports:
- 27017:27017

mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example

client:
build: client
command: yarn start
environment:
REACT_APP_SERVER: http://0.0.0.0:8080
NODE_ENV: development
CHOKIDAR_USEPOLLING: 1
ports:
- 3000:3000
volumes:
- ./client:/usr/src/app

server:
image: mikebarkmin/baby-tracker
build: server
command: yarn dev
environment:
NODE_ENV: development
DATABASE_URL: mongodb://server:test@mongo:27017/baby-tracker

ports:
- 8080:8080

volumes:
- ./server:/usr/src/app
1 change: 0 additions & 1 deletion server/.dockerignore

This file was deleted.

35 changes: 0 additions & 35 deletions server/docker-compose.yml

This file was deleted.

4 changes: 2 additions & 2 deletions server/package.json
@@ -1,10 +1,10 @@
{
"name": "baby-tracker",
"version": "1.0.0",
"version": "1.3.1",
"main": "server.js",
"author": "Mike Barkmin",
"license": "MIT",
"private": false,
"private": true,
"scripts": {
"start": "node src/server.js",
"dev": "DEBUG=socket.io* nodemon --exec babel-node src/server.js localhost 8080",
Expand Down

0 comments on commit d59199f

Please sign in to comment.