Skip to content

Commit

Permalink
Docker image based on Alpine Linux (#1434)
Browse files Browse the repository at this point in the history
Co-authored-by: Twice <twice.mliu@gmail.com>
Co-authored-by: hulk <hulk.website@gmail.com>
  • Loading branch information
3 people authored May 17, 2023
1 parent 27e843c commit a398c6f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
**/.git
**/.gitignore
**/.github
**/tests
Dockerfile
39 changes: 24 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 -DPORTABLE=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=10s --timeout=1s --start-period=30s --retries=3 CMD ./bin/redis-cli -p 6666 PING | grep -E '(PONG|NOAUTH)' || exit 1

COPY --from=build /kvrocks/tools/redis-cli ./bin/
ENV PATH="$PATH:/kvrocks/bin"

VOLUME /var/lib/kvrocks

RUN chown kvrocks:kvrocks /var/lib/kvrocks

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

EXPOSE 6666:6666
ENTRYPOINT ["./bin/kvrocks", "-c", "/var/lib/kvrocks/kvrocks.conf", "--dir", "/var/lib/kvrocks"]

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

0 comments on commit a398c6f

Please sign in to comment.