Skip to content

Commit 981bb46

Browse files
committed
add dockerfile
1 parent e66211a commit 981bb46

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ui/node_modules/

Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM alpine:3.7
2+
3+
COPY api/api /api
4+
COPY ui/build /ui/build
5+
6+
RUN chmod +x /api
7+
8+
CMD ["/api"]

Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
REGISTRY="registry.digitalocean.com/studentelwin"
2+
3+
build-ui:
4+
cd ui; npm run build;
5+
6+
build-api:
7+
cd api; GOOS=linux GOARCH=amd64 go build;
8+
9+
publish: build-api build-ui
10+
docker build . -t chat
11+
docker tag chat $(REGISTRY)/chat
12+
docker push $(REGISTRY)/chat

api/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api

api/go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
2929
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
3030
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
3131
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
32+
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
3233
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3334
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
3435
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

api/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func main() {
1919
e := echo.New()
2020
e.Use(middleware.Logger())
2121

22-
e.GET("/", func(c echo.Context) error {
23-
return c.JSON(http.StatusOK, "ok")
24-
})
22+
e.Static("/", "/ui/build")
23+
24+
api := e.Group("/api")
2525

26-
e.GET("/ws", func(c echo.Context) error {
26+
api.GET("/ws", func(c echo.Context) error {
2727
upgrader := websocket.Upgrader{
2828
CheckOrigin: func(r *http.Request) bool { return true },
2929
}
@@ -47,7 +47,7 @@ func main() {
4747
return nil
4848
})
4949

50-
e.GET("/users", func(c echo.Context) error {
50+
api.GET("/users", func(c echo.Context) error {
5151
return c.JSONPretty(http.StatusOK, users, " ")
5252
})
5353

0 commit comments

Comments
 (0)