Skip to content

Commit 38e27de

Browse files
authored
Merge pull request #28 from aesrael/dockerize-app
Dockerize app
2 parents 69830b1 + 4a7ad77 commit 38e27de

37 files changed

+260
-159
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Makefile
2-
.vscode
1+
.vscode
2+
main

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Build go binary.
2+
build-go:
3+
cd ./server && make build
4+
5+
run: build-go
6+
cd server/cmd && ./main & cd ../ui/ && yarn && yarn start
7+
8+
# Build images and run
9+
docker-build:
10+
docker-compose build
11+
12+
docker-run:
13+
docker-compose --env-file ./server/.env up

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,15 @@ setup your postgres database, enter your config secrets in the [.env](./server/.
2020
- [Installing PostgreSQL for Mac, Linux, and Windows](https://medium.com/@dan.chiniara/installing-postgresql-for-windows-7ec8145698e3)
2121

2222
```bash
23-
cd server
24-
go mod download
25-
go run main.go
23+
make build-go
2624
```
2725

2826
This will start the go server.
2927

3028
To start the react app navigate to the client directory
3129

3230
```bash
33-
cd client
34-
yarn install
35-
yarn start
31+
make build-go
3632
```
3733
### Using docker
3834
using docker compose

client/.eslintrc.json

Lines changed: 0 additions & 43 deletions
This file was deleted.

client/dockerfile

Whitespace-only changes.

client/src/pages/Session.jsx

Lines changed: 0 additions & 74 deletions
This file was deleted.

docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Docker Compose file Reference (https://docs.docker.com/compose/compose-file/)
2+
version: '3'
3+
4+
services:
5+
server:
6+
build:
7+
context: ./server
8+
dockerfile: Dockerfile
9+
ports:
10+
- '8081:8081'
11+
restart: unless-stopped
12+
depends_on:
13+
- db
14+
environment:
15+
POSTGRES_SERVER_HOST: db
16+
POSTGRES_USER: ${POSTGRES_USER}
17+
POSTGRES_DB: ${POSTGRES_DB}
18+
19+
ui:
20+
build:
21+
context: ./ui
22+
dockerfile: Dockerfile
23+
ports:
24+
- '3000:3000'
25+
restart: unless-stopped
26+
27+
db:
28+
image: postgres:11.2-alpine
29+
restart: unless-stopped
30+
ports:
31+
- '5432:5432'

node_modules/.yarn-integrity

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.env

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
DB_USER=aesrael
2-
DB_PASSWORD=""
3-
DB_NAME=goapp
1+
POSTGRES_USER=postgres
2+
POSTGRES_PASSWORD=""
3+
POSTGRES_DB=postgres
44
CLIENT_URL=http://localhost:3000
55
SERVER_PORT=:8081
66
JWT_KEY=secretive

server/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# Build go binary.
3+
build:
4+
cd cmd && go build -o main .
5+
6+
run:
7+
cd cmd && ./main
8+
9+
build-run: build run

0 commit comments

Comments
 (0)