Skip to content

Commit

Permalink
build: tidy dockerfile (#1477)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored May 27, 2023
1 parent e066781 commit bb8c3c2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 29 deletions.
59 changes: 54 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
**/.git
**/.gitignore
**/.github
**/tests
Dockerfile
/.git
/.gitignore
/.github
/tests
/Dockerfile

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

*.pyc
*.swp
*.swo
.DS_Store
version.h

.idea
.vscode
.cache

compactdb
testdb

build
cmake-build-*
31 changes: 7 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ FROM alpine:3.16 as build

ARG MORE_BUILD_ARGS

# workaround tzdata install hanging
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apk update && apk add git gcc g++ make cmake ninja autoconf automake libtool python3 linux-headers curl openssl-dev libexecinfo-dev redis
WORKDIR /kvrocks

Expand All @@ -31,36 +27,23 @@ RUN ./x.py build -DENABLE_OPENSSL=ON -DPORTABLE=ON -DCMAKE_BUILD_TYPE=Release -j

FROM alpine:3.16

ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apk upgrade && apk add libexecinfo

WORKDIR /kvrocks

RUN mkdir /var/run/kvrocks && mkdir /var/lib/kvrocks

RUN addgroup -S kvrocks && adduser -D -H -S -G kvrocks kvrocks

RUN chown kvrocks:kvrocks /var/run/kvrocks && chown kvrocks:kvrocks /var/lib/kvrocks

USER kvrocks

COPY --from=build /kvrocks/build/kvrocks ./bin/
COPY --from=build /usr/bin/redis-cli ./bin/

HEALTHCHECK --interval=10s --timeout=1s --start-period=30s --retries=3 CMD ./bin/redis-cli -p 6666 PING | grep -E '(PONG|NOAUTH)' || exit 1

ENV PATH="$PATH:/kvrocks/bin"

VOLUME /var/lib/kvrocks

RUN chown kvrocks:kvrocks /var/lib/kvrocks
COPY --from=build /kvrocks/build/kvrocks /bin/
COPY --from=build /usr/bin/redis-cli /bin/

HEALTHCHECK --interval=10s --timeout=1s --start-period=30s --retries=3 \
CMD ./bin/redis-cli -p 6666 PING | grep -E '(PONG|NOAUTH)' || exit 1

COPY ./LICENSE ./NOTICE ./DISCLAIMER ./
COPY ./licenses ./licenses
COPY ./LICENSE ./NOTICE ./DISCLAIMER ./licenses /kvrocks/
COPY ./kvrocks.conf /var/lib/kvrocks/

EXPOSE 6666:6666

ENTRYPOINT ["./bin/kvrocks", "-c", "/var/lib/kvrocks/kvrocks.conf", "--dir", "/var/lib/kvrocks", "--pidfile", "/var/run/kvrocks/kvrocks.pid"]
ENTRYPOINT ["kvrocks", "-c", "/var/lib/kvrocks/kvrocks.conf", "--dir", "/var/lib/kvrocks", "--pidfile", "/var/run/kvrocks/kvrocks.pid"]

0 comments on commit bb8c3c2

Please sign in to comment.