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

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

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


##########
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:
   I am wondering whether it will work well if users set `requirepass` in config



##########
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

Review Comment:
   I think `-DPORTABLE=ON` cannot be removed, since the build machine will have different arch version compared to the user machine (e.g. if avx512 in the build machine but not in the user machine, users will get "illegal instruction" crash).
   And I think we use `RelWithDebInfo` instead of `Release` since we want to keep the debug info in the binary (which may make the binary more large). These options, like `-DCMAKE_BUILD_TYPE=Release` and `-j $(nproc)`, can also be passed from `MORE_BUILD_ARGS`, e.g. `docker build --build-arg MORE_BUILD_ARGS=...` (maybe, not confirmed yet) if you want these options.



-- 
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