mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-18 01:46:45 +00:00
docker-compose setup
This commit is contained in:
parent
bbec2d8ccf
commit
017ed14462
47
DOCS.md
47
DOCS.md
@ -2,53 +2,12 @@
|
|||||||
|
|
||||||
## Installation (Docker)
|
## Installation (Docker)
|
||||||
|
|
||||||
Prerequisites:
|
1. *(Optional)* Tweak configuration file
|
||||||
* You have a postgres container using the network `tt`, listening
|
|
||||||
for connections on `172.26.0.2:5432`.
|
|
||||||
Example:
|
|
||||||
`docker run -d --name tt_pg --network tt postgres:alpine`
|
|
||||||
|
|
||||||
|
|
||||||
1. Initialize the database
|
|
||||||
|
|
||||||
```bash
|
|
||||||
psql -h 172.26.0.2 -U postgres
|
|
||||||
> CREATE USER task_tracker;
|
|
||||||
> CREATE database task_tracker;
|
|
||||||
```
|
|
||||||
1. Write configuration file
|
|
||||||
|
|
||||||
`vim config.yml`
|
`vim config.yml`
|
||||||
```yaml
|
|
||||||
server:
|
|
||||||
address: "localhost:3010"
|
|
||||||
database:
|
|
||||||
conn_str: "postgres://task_tracker:task_tracker@172.26.0.2/task_tracker?sslmode=disable"
|
|
||||||
log_levels: ["error", "info", "warn"]
|
|
||||||
git:
|
|
||||||
webhook_hash: "sha256"
|
|
||||||
webhook_sig_header: "X-Gogs-Signature"
|
|
||||||
log:
|
|
||||||
level: "trace"
|
|
||||||
session:
|
|
||||||
cookie_name: "tt"
|
|
||||||
expiration: "8h"
|
|
||||||
monitoring:
|
|
||||||
snapshot_interval: "120s"
|
|
||||||
history_length: "400h"
|
|
||||||
maintenance:
|
|
||||||
reset_timed_out_tasks_interval: "5m"
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Create task_tracker container:
|
1.
|
||||||
|
`docker-compose up`
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run --rm\
|
|
||||||
-v $PWD/config.yml:/root/config.yml\
|
|
||||||
--network tt\
|
|
||||||
-p 0.0.0.0:12345:80\
|
|
||||||
simon987/task_tracker
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installation (Linux)
|
## Installation (Linux)
|
||||||
|
|
||||||
|
18
Dockerfile
18
Dockerfile
@ -1,5 +1,5 @@
|
|||||||
# Build API
|
# Build API
|
||||||
FROM golang:1.11.5 as go_build
|
FROM golang:1.13 as go_build
|
||||||
WORKDIR /go/src/github.com/simon987/task_tracker/
|
WORKDIR /go/src/github.com/simon987/task_tracker/
|
||||||
|
|
||||||
COPY .git .git
|
COPY .git .git
|
||||||
@ -10,17 +10,11 @@ COPY main main
|
|||||||
COPY storage storage
|
COPY storage storage
|
||||||
RUN go get ./main/ && GOOS=linux CGO_ENABLED=0 go build -a -installsuffix cgo -o tt_api ./main/
|
RUN go get ./main/ && GOOS=linux CGO_ENABLED=0 go build -a -installsuffix cgo -o tt_api ./main/
|
||||||
|
|
||||||
# Build Web
|
FROM scratch
|
||||||
FROM node:10-alpine as npm_build
|
|
||||||
COPY ./web/ ./
|
|
||||||
RUN cd ./angular/ && npm install
|
|
||||||
RUN cd ./angular/ && ./node_modules/@angular/cli/bin/ng build --prod --optimization --output-path "/webroot"
|
|
||||||
|
|
||||||
FROM nginx:alpine
|
WORKDIR /root/
|
||||||
WORKDIR /root
|
|
||||||
|
|
||||||
COPY nginx.conf schema.sql config.yml ./
|
COPY --from=go_build ["/go/src/github.com/simon987/task_tracker/tt_api", "/root/"]
|
||||||
COPY --from=go_build ["/go/src/github.com/simon987/task_tracker/tt_api", "./"]
|
COPY ["config.yml", "schema.sql", "/root/"]
|
||||||
COPY --from=npm_build ["/webroot", "/webroot"]
|
|
||||||
|
|
||||||
CMD ["sh", "-c", "nginx -c /root/nginx.conf && /root/tt_api"]
|
CMD ["/root/tt_api"]
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
server:
|
server:
|
||||||
address: "localhost:3010"
|
address: "0.0.0.0:3010"
|
||||||
|
|
||||||
database:
|
database:
|
||||||
conn_str: "user=task_tracker password=task_tracker dbname=task_tracker sslmode=disable"
|
conn_str: "postgres://task_tracker:task_tracker@tt_db/task_tracker?sslmode=disable"
|
||||||
# log_levels: ["debug", "error", "trace", "info", "warn"]
|
# log_levels: ["debug", "error", "trace", "info", "warn"]
|
||||||
log_levels: ["error", "info", "warn"]
|
log_levels: ["error", "info", "warn"]
|
||||||
|
|
||||||
|
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
version: "2.1"
|
||||||
|
services:
|
||||||
|
tt:
|
||||||
|
build: .
|
||||||
|
depends_on:
|
||||||
|
tt_db:
|
||||||
|
condition: service_healthy
|
||||||
|
tt_web:
|
||||||
|
build: web/
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
depends_on:
|
||||||
|
tt:
|
||||||
|
condition: service_started
|
||||||
|
tt_db:
|
||||||
|
image: postgres
|
||||||
|
# volumes:
|
||||||
|
# - ./tt_db_data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
- "POSTGRES_USER=task_tracker"
|
||||||
|
- "POSTGRES_PASSWORD=task_tracker"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U task_tracker"]
|
||||||
|
interval: 3s
|
||||||
|
timeout: 2s
|
||||||
|
retries: 10
|
||||||
|
|
@ -25,6 +25,9 @@ func (database *Database) ResetTimedOutTasks() {
|
|||||||
WHERE status=1 AND assignee IS NOT NULL
|
WHERE status=1 AND assignee IS NOT NULL
|
||||||
AND extract(epoch from now() at time zone 'utc') > (assign_time + max_assign_time);`)
|
AND extract(epoch from now() at time zone 'utc') > (assign_time + max_assign_time);`)
|
||||||
handleErr(err)
|
handleErr(err)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
rowsAffected, _ := res.RowsAffected()
|
rowsAffected, _ := res.RowsAffected()
|
||||||
|
|
||||||
|
12
web/Dockerfile
Normal file
12
web/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
FROM node:10-alpine as npm_build
|
||||||
|
COPY ./ ./
|
||||||
|
RUN cd ./angular/ && npm install
|
||||||
|
RUN cd ./angular/ && ./node_modules/@angular/cli/bin/ng build --prod --optimization --output-path "/webroot"
|
||||||
|
|
||||||
|
FROM nginx:alpine
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
COPY nginx.conf /etc/nginx/
|
||||||
|
COPY --from=npm_build ["/webroot", "/webroot"]
|
||||||
|
|
||||||
|
EXPOSE 80
|
@ -24,6 +24,10 @@ http {
|
|||||||
|
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
upstream api {
|
||||||
|
server tt:3010;
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
|
|
||||||
@ -39,7 +43,7 @@ http {
|
|||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection 'upgrade';
|
proxy_set_header Connection 'upgrade';
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_pass http://127.0.0.1:3010$1?$args;
|
proxy_pass http://api$1?$args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user