Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Backend
MONGO_URI=mongodb://mongo:27017/clockify
JWT_SECRET=replace-with-strong-secret

# Frontend
REACT_APP_API_URL=http://localhost:5000/api
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ To run this application on your local system
- Authorise
- Use the application

## Docker (one-command setup)
1. Copy the environment template and adjust values as needed:
```bash
cp .env.example .env
```
2. Build and start everything:
```bash
docker compose up --build
```
3. Open the app:
- Frontend: http://localhost:3006
- Backend: http://localhost:5000

## Features
<!-- --- -->
- There is login and logout functionality.
Expand Down
5 changes: 5 additions & 0 deletions clockify/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
Dockerfile
.dockerignore
.env
12 changes: 12 additions & 0 deletions clockify/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci

COPY . .

EXPOSE 3006

CMD ["npm", "start"]
2 changes: 1 addition & 1 deletion clockify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "set PORT=3006 && react-scripts start",
"start": "PORT=3006 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down
4 changes: 3 additions & 1 deletion clockify/src/Redux/Auth/Auth.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import axios from "axios";
import { error, loading, register } from "./Auth.types";
import { toast } from "react-toastify";

const API_URL = `https://clcok2.onrender.com/api/users/`;
const API_BASE_URL =
process.env.REACT_APP_API_URL || "https://clcok2.onrender.com/api";
const API_URL = `${API_BASE_URL}/users/`;

const toastOptions = {
position: "bottom-left",
Expand Down
4 changes: 3 additions & 1 deletion clockify/src/Redux/Tasks/Task.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
} from "./Task.types";
import axios from "axios";

const API_URL = `https://clcok2.onrender.com/api/goals/`;
const API_BASE_URL =
process.env.REACT_APP_API_URL || "https://clcok2.onrender.com/api";
const API_URL = `${API_BASE_URL}/goals/`;

export const startTask = (payload) => (dispatch) => {
dispatch({ type: start, payload: payload });
Expand Down
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.9"

services:
mongo:
image: mongo:6
restart: unless-stopped
volumes:
- mongo_data:/data/db
ports:
- "27017:27017"

server:
build:
context: ./server
restart: unless-stopped
env_file:
- ./.env
environment:
- PORT=5000
- MONGO_URI=${MONGO_URI:-mongodb://mongo:27017/clockify}
depends_on:
- mongo
ports:
- "5000:5000"

client:
build:
context: ./clockify
restart: unless-stopped
environment:
- PORT=3006
- REACT_APP_API_URL=${REACT_APP_API_URL:-http://localhost:5000/api}
depends_on:
- server
ports:
- "3006:3006"

volumes:
mongo_data:
5 changes: 5 additions & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
Dockerfile
.dockerignore
.env
12 changes: 12 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --omit=dev

COPY . .

EXPOSE 5000

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