You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "aleksraiden (via GitHub)" <gi...@apache.org> on 2023/05/10 20:09:47 UTC

[GitHub] [incubator-kvrocks] aleksraiden commented on a diff in pull request #1434: Docker image based on Alpine Linux

aleksraiden commented on code in PR #1434:
URL: https://github.com/apache/incubator-kvrocks/pull/1434#discussion_r1190348857


##########
Dockerfile:
##########
@@ -15,43 +15,52 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM ubuntu:focal as build
+FROM alpine:3.16 as build
 
 ARG MORE_BUILD_ARGS
 
 # workaround tzdata install hanging
-ENV TZ=Asia/Shanghai
+ENV TZ=Etc/UTC
 RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
 
-RUN apt update && apt install -y git gcc g++ make cmake autoconf automake libtool python3 libssl-dev curl
+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
 
 COPY . .
-RUN ./x.py build -DENABLE_OPENSSL=ON -DPORTABLE=ON $MORE_BUILD_ARGS
+RUN ./x.py build -DENABLE_OPENSSL=ON -DCMAKE_BUILD_TYPE=Release -j $(nproc) $MORE_BUILD_ARGS
 
-RUN curl -O https://download.redis.io/releases/redis-6.2.7.tar.gz && \
-    tar -xzvf redis-6.2.7.tar.gz && \
-    mkdir tools && \
-    cd redis-6.2.7 && \
-    make redis-cli && \
-    mv src/redis-cli /kvrocks/tools/redis-cli
+FROM alpine:3.16
 
-FROM ubuntu:focal
+ENV TZ=Etc/UTC
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
 
-RUN apt update && apt install -y libssl-dev
+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=5s --timeout=1s --start-period=5s --retries=3 CMD ./bin/redis-cli -p 6666 PING | grep PONG || exit 1

Review Comment:
   Oh, thanks! I have a hard thinking for this issue. So, a way with a require password in params are so unclean and not like to me. 
   
   We have a two way for this:
   
   1. Changing PING command for using without AUTH (Better for me, but need to patch kvrocks)
   2. Changing an healthcheck to this "./bin/redis-cli -p 6666 PING |  -E '(PONG|NOAUTH)'  || exit 1" - so if server require password, an NOAUTH response also tell us that's server are alive.
   
   I think, second scenario is simplest way at now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org