File tree 5 files changed +69
-4
lines changed
5 files changed +69
-4
lines changed Original file line number Diff line number Diff line change
1
+ # To build:
2
+ # make docker-build
3
+ # To push:
4
+ # make docker-push
5
+
6
+ FROM golang:1.22.4-bullseye as build
7
+ ARG GIT_COMMIT
8
+
9
+ WORKDIR /src/wallet-backend
10
+ ADD go.mod go.sum ./
11
+ RUN go mod download
12
+ ADD . ./
13
+ RUN go build -o /bin/wallet-backend -ldflags "-X main.GitCommit=$GIT_COMMIT" .
14
+
15
+
16
+ FROM ubuntu:22.04
17
+
18
+ RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates
19
+ COPY --from=build /bin/wallet-backend /app/
20
+ EXPOSE 8001
21
+ WORKDIR /app
22
+ ENTRYPOINT ["./wallet-backend" ]
Original file line number Diff line number Diff line change
1
+ # Check if we need to prepend docker command with sudo
2
+ SUDO := $(shell docker version >/dev/null 2>&1 || echo "sudo")
3
+
4
+ LABEL ?= $(shell git rev-parse --short HEAD)$(and $(shell git status -s) ,-dirty-$(shell id -u -n) )
5
+ # If TAG is not provided set default value
6
+ TAG ?= stellar/wallet-backend:$(LABEL )
7
+ # https://github.com/opencontainers/image-spec/blob/master/annotations.md
8
+ BUILD_DATE := $(shell date -u +% FT% TZ)
9
+
10
+ docker-build :
11
+ $(SUDO ) docker build -f Dockerfile --pull --label org.opencontainers.image.created=" $( BUILD_DATE) " -t $(TAG ) --build-arg GIT_COMMIT=$(LABEL ) .
12
+
13
+ docker-push :
14
+ $(SUDO ) docker push $(TAG )
15
+
16
+ go-install :
17
+ go install -ldflags " -X main.GitCommit=$( LABEL) " .
Original file line number Diff line number Diff line change @@ -24,15 +24,15 @@ func (c *serveCmd) Command() *cobra.Command {
24
24
Usage : "Port to listen and serve on" ,
25
25
OptType : types .Int ,
26
26
ConfigKey : & cfg .Port ,
27
- FlagDefault : 8000 ,
27
+ FlagDefault : 8001 ,
28
28
Required : false ,
29
29
},
30
30
{
31
31
Name : "server-base-url" ,
32
32
Usage : "The server base URL" ,
33
33
OptType : types .String ,
34
34
ConfigKey : & cfg .ServerBaseURL ,
35
- FlagDefault : "http://localhost:8000 " ,
35
+ FlagDefault : "http://localhost:8001 " ,
36
36
Required : true ,
37
37
},
38
38
{
Original file line number Diff line number Diff line change 1
- version : ' 3.8'
2
1
services :
3
2
db :
4
3
image : postgres:12-alpine
@@ -9,6 +8,27 @@ services:
9
8
- postgres-db:/var/lib/postgresql/data
10
9
ports :
11
10
- 5432:5432
11
+ api :
12
+ image : stellar/wallet-backend:development
13
+ build : ./
14
+ depends_on :
15
+ db :
16
+ condition : service_started
17
+ ports :
18
+ - 8001:8001
19
+ entrypoint : " "
20
+ command :
21
+ - sh
22
+ - -c
23
+ - |
24
+ ./wallet-backend migrate up
25
+ ./wallet-backend serve
26
+ environment :
27
+ DATABASE_URL : postgres://postgres@db:5432/wallet-backend?sslmode=disable
28
+ PORT : 8001
29
+ SERVER_BASE_URL : http://localhost:8001
30
+ LOG_LEVEL : TRACE
31
+ WALLET_SIGNING_KEY : GAXBXPBZNJG6PQBE7M3VTEZ4EIRVDL4TSTQEVHEOYOLMYQZWJ4WUA4YF
12
32
13
33
volumes :
14
34
postgres-db :
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
- import "github.com/stellar/wallet-backend/cmd"
3
+ import (
4
+ "github.com/stellar/wallet-backend/cmd"
5
+ )
6
+
7
+ // GitCommit is populated at build time by
8
+ // go build -ldflags "-X main.GitCommit=$GIT_COMMIT"
9
+ var GitCommit string
4
10
5
11
func main () {
6
12
cmd .Execute ()
You can’t perform that action at this time.
0 commit comments