Skip to content

Commit 055e472

Browse files
add Dockerfile and make target
1 parent bc20162 commit 055e472

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

.dockerignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git/
2+
.github
3+
assets/
4+
bin/
5+
test/
6+
tmp/
7+
LICENSE
8+
README.md
9+
Makefile

Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:1.22-alpine3.20 AS builder
2+
3+
RUN mkdir /app && mkdir -p /usr/local/src/smolgit
4+
WORKDIR /usr/local/src/smolgit
5+
6+
ADD ./go.mod ./go.sum ./
7+
RUN go mod download
8+
ADD . ./
9+
10+
RUN go build -v -o /build/smolgit
11+
12+
FROM alpine/git:2.45.2 AS runner
13+
14+
COPY --from=builder /build/smolgit /usr/bin/smolgit
15+
16+
EXPOSE 3080
17+
EXPOSE 3081
18+
ENTRYPOINT ["/usr/bin/smolgit", "--config", "/etc/smolgit/config.yaml"]

Makefile

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ all: help
1818
build: ## Build all the binaries and put the output in bin/
1919
$(GOCMD) build -ldflags "-X main.version=$(BRANCH)-$(HASH)" -o bin/$(PROJECT_NAME) .
2020

21+
build-docker: ## Build an image
22+
docker build -t $(PROJECT_NAME) .
23+
2124
## Clean:
2225
clean: ## Remove build related file
2326
@-rm -fr ./bin
@@ -26,6 +29,12 @@ clean: ## Remove build related file
2629
run: clean build ## Run the smolgit `make run`
2730
./bin/$(PROJECT_NAME) $(ARGS)
2831

32+
run-docker: ## Run smolgit in the container
33+
docker run -it -p 3080:3080 -p 3081:3081 -v $(PWD)/:/etc/smolgit $(PROJECT_NAME)
34+
35+
config-docker: ## Generate smolgit config
36+
docker run -it $(PROJECT_NAME) config > config.yaml
37+
2938
config: ## Generate default config
3039
./bin/$(PROJECT_NAME) config > ./config.yaml
3140

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Install](#install)
1111
- [Run](#run)
1212
- [Config](#config)
13+
- [Docker](#docker)
1314
- [Prerequisites](#prerequisites)
1415
- [Built with](#built-with)
1516
- [Contribution](#contribution)
@@ -112,6 +113,25 @@ Usage of ./smolgit:
112113
path to config (default "./config.yaml")
113114
```
114115

116+
#### Docker
117+
118+
In order to run `smolgit` in docker there is the [`Dockerfile`](/Dockerfile).
119+
120+
1. Build image `make build-docker`
121+
1. Generate `config.yaml` file `make config-docker`, it'll create `config.yaml` in the current directory and mount it for docker.
122+
1. Run `smolgit` in docker:
123+
124+
```shell
125+
$> make run-docker
126+
docker run -it -p 3080:3080 -p 3081:3081 -v /path-to-smolgit-project/smolgit/:/etc/smolgit smolgit
127+
3:53PM INF set loglevel level=DEBUG
128+
3:53PM INF version version=dev
129+
3:53PM INF initialize web server addr=:3080
130+
3:53PM INF initialize ssh server addr=:3081
131+
3:53PM INF start server brand=smolgit address=:3080
132+
3:53PM INF starting SSH server addr=:3081
133+
```
134+
115135
### Prerequisites
116136

117137
- git

0 commit comments

Comments
 (0)