Skip to content

Commit

Permalink
chore(docker): Simplify the main Dockerfile
Browse files Browse the repository at this point in the history
The main Dockerfile is meant to be used by many automatic tools
such as automatic cloud runners, scanners etc. Thsi file must be
kept minimal to minimize build time and provide an easy to modify
example dockerfile for immudb.

Signed-off-by: Bartłomiej Święcki <bart@codenotary.com>
  • Loading branch information
Bartłomiej Święcki committed Sep 6, 2022
1 parent 74288a0 commit 2848002
Showing 1 changed file with 15 additions and 44 deletions.
59 changes: 15 additions & 44 deletions Dockerfile
@@ -1,3 +1,17 @@
# Copyright 2022 Codenotary Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.18 as build
WORKDIR /src
COPY go.mod go.sum /src/
Expand All @@ -7,50 +21,7 @@ RUN rm -rf /src/webconsole/dist
RUN GOOS=linux GOARCH=amd64 WEBCONSOLE=default make immuadmin-static immudb-static
RUN mkdir /empty

FROM debian:bullseye-slim as bullseye-slim
LABEL org.opencontainers.image.authors="Codenotary Inc. <info@codenotary.com>"

COPY --from=build /src/immudb /usr/sbin/immudb
COPY --from=build /src/immuadmin /usr/local/bin/immuadmin
COPY --from=build "/etc/ssl/certs/ca-certificates.crt" "/etc/ssl/certs/ca-certificates.crt"

ARG IMMU_UID="3322"
ARG IMMU_GID="3322"

ENV IMMUDB_HOME="/usr/share/immudb" \
IMMUDB_DIR="/var/lib/immudb" \
IMMUDB_ADDRESS="0.0.0.0" \
IMMUDB_PORT="3322" \
IMMUDB_PIDFILE="" \
IMMUDB_LOGFILE="" \
IMMUDB_MTLS="false" \
IMMUDB_AUTH="true" \
IMMUDB_DETACHED="false" \
IMMUDB_DEVMODE="true" \
IMMUDB_MAINTENANCE="false" \
IMMUDB_ADMIN_PASSWORD="immudb" \
IMMUDB_PGSQL_SERVER="true" \
IMMUADMIN_TOKENFILE="/var/lib/immudb/admin_token"

RUN addgroup --system --gid $IMMU_GID immu && \
adduser --system --uid $IMMU_UID --no-create-home --ingroup immu immu && \
mkdir -p "$IMMUDB_HOME" && \
mkdir -p "$IMMUDB_DIR" && \
chown -R immu:immu "$IMMUDB_HOME" "$IMMUDB_DIR" && \
chmod -R 777 "$IMMUDB_HOME" "$IMMUDB_DIR" && \
chmod +x /usr/sbin/immudb /usr/local/bin/immuadmin

EXPOSE 3322
EXPOSE 9497
EXPOSE 8080
EXPOSE 5432

HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/usr/local/bin/immuadmin", "status" ]
USER immu
ENTRYPOINT ["/usr/sbin/immudb"]


FROM scratch as scratch
FROM scratch
LABEL org.opencontainers.image.authors="Codenotary Inc. <info@codenotary.com>"

ARG IMMU_UID="3322"
Expand Down

0 comments on commit 2848002

Please sign in to comment.