Skip to content

Commit 30b2605

Browse files
committed
chore: add script to build docker image to run ghfs
1 parent b962075 commit 30b2605

File tree

13 files changed

+90
-2
lines changed

13 files changed

+90
-2
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!.git
3+
!src/
4+
!build/
5+
!conf/docker-image

build/build-all-by-docker.sh

100644100755
File mode changed.

build/build-all.inc.sh

100644100755
File mode changed.

build/build-all.sh

100644100755
File mode changed.

build/build-current.sh

100644100755
File mode changed.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM golang AS builder
2+
ENV GO111MODULE=auto
3+
COPY .git/ /mnt/ghfs/.git/
4+
COPY src/ /mnt/ghfs/src/
5+
COPY build/ /mnt/ghfs/build/
6+
RUN ["/bin/bash", "-c", "cd /mnt/ghfs/build/; source ./build.inc.sh; go build -ldflags \"$LDFLAGS\" -o /tmp/ghfs /mnt/ghfs/src/main.go"]
7+
RUN mkdir -p /output/usr/local/bin/; cp /tmp/ghfs /output/usr/local/bin/;
8+
COPY conf/docker-image/ /output/
9+
10+
FROM alpine
11+
COPY --from=builder /output /
12+
RUN mkdir /lib64 /var/ghfs; ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
13+
VOLUME /var/ghfs
14+
EXPOSE 8080 8443
15+
USER nobody
16+
CMD [ \
17+
"/usr/local/bin/ghfs", \
18+
"--listen-plain", "8080", "-r", "/var/ghfs/", \
19+
",,", \
20+
"--listen-tls", "8443", "-c", "/etc/server.crt", "-k", "/etc/server.key", "-r", "/var/ghfs/" \
21+
]

build/build-docker-image.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
cd $(dirname "$0")
4+
source ./build.inc.version.sh
5+
6+
TAG_PREFIX=${TAG_PREFIX:-mjpclab/ghfs}
7+
8+
docker build -t "$TAG_PREFIX:latest" -t "$TAG_PREFIX:$VERSION" -f ./build-docker-image-dockerfile ../

build/build.inc.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ TMP='/tmp'
22
OUTDIR='../output'
33
MAINNAME='ghfs'
44
MOD=$(go list ../src/)
5-
VERSION=$(git describe --abbrev=0 --tags 2> /dev/null || git rev-parse --abbrev-ref HEAD 2> /dev/null)
5+
source ./build.inc.version.sh
66
LDFLAGS="-s -w -X $MOD/version.appVer=$VERSION"
77
LICENSE='../LICENSE'

build/build.inc.version.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VERSION=$(git describe --abbrev=0 --tags 2> /dev/null || git rev-parse --abbrev-ref HEAD 2> /dev/null)
2+
VERSION=${VERSION#v}

build/build.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)