Skip to content

Commit 66cf89e

Browse files
committed
dockerized the whole project
moved the server to its own folder
1 parent 4b3202f commit 66cf89e

File tree

10 files changed

+108
-34
lines changed

10 files changed

+108
-34
lines changed

client/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Dockerfile
2+
.dockerignore
3+
.gitignore
4+
.git
5+
README.md
6+
frontend.dockerfile
7+
8+
build
9+
node_modules

client/client.dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:alpine3.19
2+
3+
WORKDIR /app
4+
5+
COPY client/package*.json ./
6+
7+
RUN npm install --ignore-platform
8+
9+
COPY client/ .
10+
11+
EXPOSE 5173
12+
13+
CMD [ "npm" , "run" , "dev" ]

client/package.json

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
{
2-
"name": "client",
3-
"private": true,
4-
"version": "0.0.0",
5-
"type": "module",
6-
"scripts": {
7-
"dev": "vite",
8-
"build": "tsc -b && vite build",
9-
"lint": "eslint .",
10-
"preview": "vite preview"
11-
},
12-
"dependencies": {
13-
"@chakra-ui/react": "^2.10.3",
14-
"@emotion/react": "^11.13.3",
15-
"@emotion/styled": "^11.13.0",
16-
"@tanstack/react-query": "^5.59.15",
17-
"framer-motion": "^11.11.9",
18-
"react": "^18.3.1",
19-
"react-dom": "^18.3.1",
20-
"react-icons": "^5.3.0"
21-
},
22-
"devDependencies": {
23-
"@eslint/js": "^9.11.1",
24-
"@types/react": "^18.3.10",
25-
"@types/react-dom": "^18.3.0",
26-
"@vitejs/plugin-react": "^4.3.2",
27-
"eslint": "^9.11.1",
28-
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
29-
"eslint-plugin-react-refresh": "^0.4.12",
30-
"globals": "^15.9.0",
31-
"typescript": "^5.5.3",
32-
"typescript-eslint": "^8.7.0",
33-
"vite": "^5.4.8"
34-
}
2+
"name": "client",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite --host",
8+
"build": "tsc -b && vite build",
9+
"lint": "eslint .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"@chakra-ui/react": "^2.10.3",
14+
"@emotion/react": "^11.13.3",
15+
"@emotion/styled": "^11.13.0",
16+
"@tanstack/react-query": "^5.59.15",
17+
"framer-motion": "^11.11.9",
18+
"react": "^18.3.1",
19+
"react-dom": "^18.3.1",
20+
"react-icons": "^5.3.0"
21+
},
22+
"devDependencies": {
23+
"@eslint/js": "^9.11.1",
24+
"@types/react": "^18.3.10",
25+
"@types/react-dom": "^18.3.0",
26+
"@vitejs/plugin-react": "^4.3.2",
27+
"eslint": "^9.11.1",
28+
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
29+
"eslint-plugin-react-refresh": "^0.4.12",
30+
"globals": "^15.9.0",
31+
"typescript": "^5.5.3",
32+
"typescript-eslint": "^8.7.0",
33+
"vite": "^5.4.8"
34+
}
3535
}

docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
services:
2+
backend:
3+
container_name: go-server
4+
build:
5+
context: .
6+
dockerfile: server/server.dockerfile
7+
environment:
8+
MONGODB_URI: <db_connection_string>
9+
PORT: "5000"
10+
ENV: development
11+
ports:
12+
- "5000:5000"
13+
14+
healthcheck:
15+
interval: 2s
16+
test: "exit 0"
17+
18+
frontend:
19+
container_name: react-frontend
20+
build:
21+
context: .
22+
dockerfile: client/client.dockerfile
23+
24+
ports:
25+
- "5173:5173"
26+
depends_on:
27+
backend:
28+
condition: service_healthy

server/.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tmp
2+
backend.dockerfile
3+
.dockerignore
File renamed without changes.

go.mod renamed to server/go.mod

File renamed without changes.

go.sum renamed to server/go.sum

File renamed without changes.

main.go renamed to server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func main() {
7070
}
7171

7272
if os.Getenv("ENV") == "production" {
73-
app.Static("/", "./client/dist")
73+
app.Static("/", "./dist")
7474
}
7575

7676
log.Fatal(app.Listen("0.0.0.0:" + port))

server/server.dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# use official Golang image
2+
FROM golang:alpine3.20
3+
4+
# set working directory
5+
WORKDIR /app
6+
RUN mkdir dist
7+
8+
# Copy the source code
9+
COPY server/ .
10+
COPY client/dist ./dist
11+
# Download and install the dependencies
12+
RUN go mod tidy
13+
14+
# Build the Go app
15+
RUN go build -o todoApp .
16+
17+
#EXPOSE the port
18+
EXPOSE 5000
19+
20+
# Run the executable
21+
CMD ["./todoApp"]

0 commit comments

Comments
 (0)