Skip to content

Commit 65fa659

Browse files
Add docker-compose.
1 parent 8d0d67e commit 65fa659

File tree

6 files changed

+81
-3
lines changed

6 files changed

+81
-3
lines changed

.env

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
STORAGE_HOST=localhost
1+
STORAGE_HOST=db
22
STORAGE_PORT=5432
33
STORAGE_DBUSER=postgres
4-
STORAGE_DBPASSWORD="1772"
4+
STORAGE_DBPASSWORD=1772
55
STORAGE_HANDLERNAME=postgresql
66
STORAGE_URL=mongodb://localhost:27017
77
STORAGE_DATABASE=go_lms
8-
ADDRESS=0.0.0.0:3000
8+
ADDRESS=0.0.0.0:3000
9+
REDIS_HOST=redis

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM golang:1.14
2+
3+
WORKDIR /Go-LMS
4+
5+
COPY go.mod ./
6+
7+
RUN go mod tidy
8+
9+
RUN go mod download

docker-compose.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
build:
6+
context: ./postgres
7+
ports:
8+
- "5432"
9+
environment:
10+
- POSTGRES_DB=go_lms
11+
- POSTGRES_USER=postgres
12+
- POSTGRES_PASSWORD=1772
13+
networks:
14+
- pupilgo
15+
redis:
16+
image: "redis:alpine"
17+
restart: unless-stopped
18+
networks:
19+
- pupilgo
20+
backend:
21+
build: .
22+
command: go run cmd/api/main.go
23+
ports:
24+
- "8000:3000"
25+
restart: unless-stopped
26+
depends_on:
27+
- db
28+
- redis
29+
volumes:
30+
- ./:/Go-LMS
31+
environment:
32+
REDIS_URL: redis:6379
33+
networks:
34+
- pupilgo
35+
frontend:
36+
build: ./user-interface
37+
command: npm run start
38+
ports:
39+
- "3000:3000"
40+
depends_on:
41+
- backend
42+
volumes:
43+
- /user-interface/node_modules
44+
- ./user-interface:/user-interface
45+
networks:
46+
- pupilgo
47+
stdin_open: true
48+
49+
networks:
50+
pupilgo:

postgres/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM postgres:12.3
2+
3+
ENV POSTGRES_DB 'go_lms'
4+
ENV POSTGRES_USER 'postgres'
5+
ENV POSTGRES_PASSWORD '1772'
6+
7+
COPY load-extensions.sh /docker-entrypoint-initdb.d

postgres/load-extensions.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
psql -v ON_ERROR_STOP=1 --dbname "$POSTGRES_DB" --username "$POSTGRES_USER" <<EOF
2+
create extension "uuid-ossp";
3+
select * FROM pg_extension;
4+
EOF

user-interface/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM node:14.4
2+
3+
WORKDIR /user-interface/
4+
5+
COPY package.json ./
6+
7+
RUN npm install

0 commit comments

Comments
 (0)