Skip to content

Commit 84af658

Browse files
committed
docker: build and deploy from compose
1 parent 3518d30 commit 84af658

File tree

6 files changed

+37
-40
lines changed

6 files changed

+37
-40
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
13+
gossa
1314

1415
# Dependency directories (remove the comment below to include it)
1516
# vendor/

Makefile

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
NAME=ssaplayground
2-
BUILD=$(NAME).out
3-
IMAGE=$(NAME)
1+
NAME=gossa
42
VERSION = $(shell git describe --always --tags)
53
all: clean
6-
go build -o $(BUILD) -mod vendor
7-
./$(BUILD) -conf configs/config.yaml
8-
docker:
9-
docker build -t $(IMAGE):$(VERSION) -t $(IMAGE):latest -f docker/Dockerfile .
10-
run:
11-
docker ps -a | grep $(NAME) && ([ $$? -eq 0 ] && (docker stop $(NAME) && docker rm -f $(NAME))) || echo "no running container."
12-
docker run -itd -v $(shell pwd)/data:/app/public/buildbox -p 6789:6789 --name $(NAME) ssaplayground:latest
13-
tidy:
14-
docker ps -a | grep $(NAME)
15-
[ $$? -eq 0 ] && docker stop $(NAME) && docker rm -f $(NAME)
16-
docker images -f "dangling=true" -q | xargs docker rmi -f
17-
docker image prune -f
18-
clean:
19-
rm -rf $(BUILD)
20-
.PHONY: all docker run tidy clean
4+
go build -o $(NAME) -mod vendor
5+
./$(NAME) -conf configs/config.yaml
6+
build:
7+
docker build -t $(NAME):$(VERSION) -t $(NAME):latest -f docker/Dockerfile .
8+
up: down
9+
docker-compose -f docker/deploy.yml up -d
10+
down:
11+
docker-compose -f docker/deploy.yml down
12+
clean: down
13+
rm -rf $(NAME)
14+
docker rmi -f $(shell docker images -f "dangling=true" -q) 2> /dev/null; true
15+
docker rmi -f $(NAME):latest $(NAME):$(VERSION) 2> /dev/null; true

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ $ make
2020
If you have Docker, then you can use:
2121

2222
```bash
23-
$ make docker # build the docker image
24-
$ make run # run/update for latest image
23+
$ make build # build the docker image
24+
$ make up # run/update for latest image
2525
```
2626

2727
Then access http://localhost:6789/gossa.

TODO.md

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

docker/Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
# All rights reserved. Use of this source code is governed
33
# by a GPLv3 license that can be found in the LICENSE file.
44

5-
FROM golang:1.15.3
5+
FROM golang:1.15.6
66
WORKDIR /app
77
ADD . /app
88
# required for runtime/cgo
9-
RUN apt install g++
10-
RUN go get -u golang.org/x/tools/cmd/goimports && go mod tidy
11-
RUN go build -o ssaplayground.service -mod=readonly
12-
EXPOSE 6789
13-
ENTRYPOINT [ "/app/ssaplayground.service", "-conf=/app/configs/docker.yaml"]
9+
RUN apt install g++ && \
10+
go get -u golang.org/x/tools/cmd/goimports && go mod tidy && \
11+
go build -o gossa -mod=readonly
12+
CMD [ "/app/gossa", "-conf=/app/configs/docker.yaml"]

docker/deploy.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2020 The golang.design Initiative authors.
2+
# All rights reserved. Use of this source code is governed
3+
# by a GPLv3 license that can be found in the LICENSE file.
4+
5+
version: "3"
6+
services:
7+
gossa:
8+
container_name: gossa
9+
restart: always
10+
volumes:
11+
- ../data:/app/public/buildbox
12+
image: gossa:latest
13+
cap_add:
14+
- SYS_PTRACE # for debugging
15+
ports:
16+
- "6789:6789"

0 commit comments

Comments
 (0)