This commit is contained in:
bel
2021-09-14 06:29:17 -06:00
commit a71c585675
36 changed files with 700 additions and 0 deletions

2
leanote/.gitignore vendored Executable file
View File

@@ -0,0 +1,2 @@
data
files

54
leanote/Dockerfile Executable file
View File

@@ -0,0 +1,54 @@
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.28 as builder
RUN apk add --no-cache \
libc-dev \
gcc \
go \
git \
mongodb \
mongodb-tools
RUN mkdir -p /go/src \
&& mkdir -p /go/pkg \
&& mkdir -p /go/bin
ENV GOPATH=/go
RUN go get github.com/revel/cmd/revel \
&& go get github.com/leanote/leanote/app \
&& go get github.com/golang/dep/cmd/dep \
&& cd $GOPATH/src/github.com/revel/cmd/revel && go install \
&& cd $GOPATH/src/github.com/golang/dep/cmd/dep && go install \
&& sed -i 's/Get[\t ][ \t]*\/[\t ][\t ]*.*$/Get \/ Auth.Login/' $GOPATH/src/github.com/leanote/leanote/conf/routes
RUN mkdir -p /mnt/data \
&& mongod --dbpath /mnt/data \
& mongorestore -h localhost -d leanote --dir $GOPATH/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/ \
&& kill %1
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.28
WORKDIR /opt
ENV GOPATH=/go
RUN apk add --no-cache \
fcron \
bash \
mongodb \
go \
gcc libc-dev \
&& crond \
&& addgroup -S user && adduser -S -G user user \
&& mkdir -p \
/mnt/data \
$GOPATH/src/github.com/leanote/leanote/files
COPY --from=builder /go/src $GOPATH/src
COPY --from=builder /go/pkg $GOPATH/pkg
COPY --from=builder /go/bin $GOPATH/bin
COPY --from=builder /mnt/data /mnt/data
ENV PATH=${PATH}:$GOPATH/bin
RUN chown -R user /mnt $GOPATH
USER user
CMD []
ENTRYPOINT ["bash", "-c", "mongod --dbpath /mnt/data & revel run github.com/leanote/leanote"]

28
leanote/build_and_run.sh Executable file
View File

@@ -0,0 +1,28 @@
#! /bin/bash
set -e
img="bel/leanote"
tag="v0.0"
docker build -t $img:$tag .
if [ ! -d "$PWD/data" ]; then
mkdir "$PWD/data" "$PWD/files"
sudo chmod -R 777 "$PWD/data"
docker run --rm -it \
--entrypoint cp \
-v "$(pwd):/mnt2" \
$img:$tag \
-r /mnt/data /mnt2/
fi
sudo chmod -R 777 "$PWD/data" "$PWD/files"
docker run --rm -it \
--name ${img##*/} \
-p 9000:9000 \
-v "$(pwd)/data:/mnt/data" \
-v "$(pwd)/files:/go/src/github.com/leanote/leanote/files" \
$img:$tag

1
leanote/review Executable file
View File

@@ -0,0 +1 @@
requires mongo and only mongo. Defer.