Skip to content

Commit 114619e

Browse files
committed
[wip] restore Dockerfile
1 parent 8769f41 commit 114619e

1 file changed

Lines changed: 59 additions & 67 deletions

File tree

Dockerfile

Lines changed: 59 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,79 @@
1-
FROM ubuntu:jammy
1+
FROM alpine:3.22
22

3+
# Environment variables
34
ENV TZ=Etc/UTC
4-
55
ENV ROTATION_TZ=Etc/UTC
66

7-
ENV DEBIAN_FRONTEND=noninteractive
7+
# Install essential packages, common utilities, and set up timezone
8+
RUN apk add --no-cache \
9+
tzdata \
10+
gnupg \
11+
wget \
12+
curl \
13+
ca-certificates \
14+
openssh-client \
15+
iptables \
16+
supervisor \
17+
dirmngr \
18+
nano \
19+
vim \
20+
busybox-extras \
21+
less \
22+
tcpdump \
23+
net-tools \
24+
lsof \
25+
libaio \
26+
unzip \
27+
git && \
28+
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
29+
echo "${TZ}" > /etc/timezone
30+
31+
# Install PostgreSQL client
32+
RUN apk add --no-cache \
33+
postgresql16-client
34+
35+
# Install ClickHouse
36+
RUN cat <<EOF > /usr/local/bin/install-clickhouse.sh
37+
#!/bin/sh
38+
set -eo pipefail
839

9-
RUN echo $TZ > /etc/timezone && \
10-
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
40+
export VERSION=25.8.9.20
1141

12-
# Install required packages
13-
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && \
14-
apt-get install -y gnupg wget lsb-release curl ca-certificates openssh-client \
15-
iptables supervisor apt-transport-https dirmngr nano vim telnet less tcpdump net-tools \
16-
tzdata lsof libaio1 unzip git && \
17-
# Add PostgreSQL official repository
18-
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql.gpg && \
19-
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
20-
apt-get update -qq && \
21-
apt-get install -y postgresql-client-16 && \
22-
rm -rf /var/lib/apt/lists/*
42+
case $(uname -m) in
43+
x86_64) export ARCH=amd64 ;;
44+
aarch64) export ARCH=arm64 ;;
45+
*) echo "Unknown architecture $(uname -m)"; exit 1
46+
esac
2347

24-
# Pre-configure debconf to avoid ClickHouse prompts (password or confirmation)
25-
RUN echo "clickhouse-client clickhouse-server/root_password password root" | debconf-set-selections && \
26-
echo "clickhouse-client clickhouse-server/root_password_again password root" | debconf-set-selections
48+
for PKG in clickhouse-common-static clickhouse-client; do
49+
curl -fO /\$PKG-\$VERSION-\${ARCH}.tgz" || curl -fO "https://packages.clickhouse.com/tgz/stable/\$PKG-\$VERSION.tgz"
50+
done
2751
28-
# Install ClickHouse
29-
RUN DEBIAN_FRONTEND=noninteractive apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754 && \
30-
echo "deb https://packages.clickhouse.com/deb stable main" >> /etc/apt/sources.list && \
31-
apt-get update -qq && \
32-
apt-get install -y clickhouse-server=23.5.3.24 clickhouse-client=23.5.3.24 clickhouse-common-static=23.5.3.24 && \
33-
apt-get clean && \
34-
rm -rf /var/lib/apt/lists/*
35-
36-
ENV DOCKER_CHANNEL=stable \
37-
DOCKER_VERSION=23.0.6 \
38-
DOCKER_COMPOSE_VERSION=1.29.2 \
39-
DEBUG=false
40-
41-
# Docker installation
42-
RUN set -eux; \
43-
arch="$(uname -m)"; \
44-
case "$arch" in \
45-
x86_64) dockerArch='x86_64';; \
46-
armhf) dockerArch='armel';; \
47-
armv7) dockerArch='armhf';; \
48-
aarch64) dockerArch='aarch64';; \
49-
*) echo >&2 "error: unsupported architecture ($arch)"; exit 1;; \
50-
esac; \
51-
curl -fsSL "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-${DOCKER_VERSION}.tgz" -o docker.tgz; \
52-
tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/; \
53-
rm docker.tgz; \
54-
dockerd --version; \
55-
docker --version
56-
57-
VOLUME /var/lib/docker
52+
tar -xzvf "clickhouse-common-static-\$VERSION-\${ARCH}.tgz" || tar -xzvf "clickhouse-common-static-\$VERSION.tgz"
53+
clickhouse-common-static-\$VERSION/install/doinst.sh
54+
55+
tar -xzvf "clickhouse-client-\$VERSION-\${ARCH}.tgz" || tar -xzvf "clickhouse-client-\$VERSION.tgz"
56+
clickhouse-client-\$VERSION/install/doinst.sh
57+
EOF
58+
59+
RUN chmod +x /usr/local/bin/install-clickhouse.sh && /usr/local/bin/install-clickhouse.sh && rm -f /usr/local/bin/install-clickhouse.sh
5860
5961
# Create a non-root user and group
60-
RUN addgroup --system trcligroup && adduser --system --ingroup trcligroup trcliuser
62+
# Alpine uses -S for system users/groups.
63+
RUN addgroup -S trcligroup && \
64+
adduser -S -G trcligroup trcliuser
6165
62-
# Copy the Go binary
66+
# Copy the Go binary
6367
COPY trcli /usr/local/bin/trcli
6468
69+
# Set executable permission
6570
RUN chmod +x /usr/local/bin/trcli
6671
67-
# Switch to the non-root user
72+
# Switch to the non-root user
6873
USER trcliuser
6974
70-
# Supervisor configuration to start Docker daemon and application
75+
# Switch back to root before ENTRYPOINT
7176
USER root
72-
RUN apt-get install -y supervisor
73-
74-
RUN echo "[supervisord]\n\
75-
nodaemon=true\n\
76-
\n\
77-
[program:dockerd]\n\
78-
command=/usr/local/bin/dockerd --host=unix:///var/run/docker.sock\n\
79-
autostart=true\n\
80-
autorestart=true\n\
81-
stdout_logfile=/var/log/dockerd.out.log\n\
82-
stderr_logfile=/var/log/dockerd.err.log\n" \
83-
> /etc/supervisor/supervisord.conf
84-
85-
ENV SUPERVISORD_PATH=/etc/supervisor/supervisord.conf
8677
78+
# Entrypoint
8779
ENTRYPOINT ["/usr/local/bin/trcli"]

0 commit comments

Comments
 (0)