From 3d6699381a79b2b0db45364d4e8feb24f91929d0 Mon Sep 17 00:00:00 2001 From: balzack Date: Sun, 10 Mar 2024 20:42:13 -0700 Subject: [PATCH] reducing docker image size further --- net/container/Dockerfile | 16 ++++++++++++++-- net/container/dev_setup.sh | 20 ++++++++++++++++++++ net/container/entrypoint.sh | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100755 net/container/dev_setup.sh diff --git a/net/container/Dockerfile b/net/container/Dockerfile index 94fd98fe..56560e28 100644 --- a/net/container/Dockerfile +++ b/net/container/Dockerfile @@ -41,12 +41,24 @@ RUN echo "set expandtab\nset tabstop=2\nset softtabstop=2\nset shiftwidth=2\nset RUN echo "bind 'set mark-symlinked-directories on'" >> /root/.bashrc ADD entrypoint.sh /app +ADD dev_setup.sh /app + +RUN rm -rf /usr/local/go +RUN rm -rf /root/go +RUN rm -rf /app/go* +RUN rm -rf /root/.cache/go* RUN yarn cache clean +RUN rm -rf /app/databag/app RUN rm -rf /app/databag/net/web/node_modules -RUN rm -rf /var/lib/apt/lists -RUN apt-get -y remove git build-essential npm +RUN n prune +RUN npm uninstall -g n +RUN rm -rf /usr/local/n +RUN rm -rf /usr/local/bin/node + +RUN apt-get -y remove git build-essential npm vim nodejs +RUN rm -rf /var/lib/apt/lists FROM scratch COPY --from=build / / diff --git a/net/container/dev_setup.sh b/net/container/dev_setup.sh new file mode 100755 index 00000000..9f330441 --- /dev/null +++ b/net/container/dev_setup.sh @@ -0,0 +1,20 @@ +cd /root +wget -P /app https://go.dev/dl/go1.18.10.linux-amd64.tar.gz +tar -C /usr/local -xzf /app/go1.18.10.linux-amd64.tar.gz + +apt-get update +apt-get -y install git build-essential npm vim + +curl -fsSL https://deb.nodesource.com/setup_18.x | bash - +apt install -y nodejs + +npm install --global yarn +npm install -g n +n stable + +cd /app/databag +git checkout . + +yarn --cwd /app/databag/net/web install +yarn --cwd /app/databag/net/web build +cd /app/databag/net/server; /usr/local/go/bin/go build databag diff --git a/net/container/entrypoint.sh b/net/container/entrypoint.sh index f38fcfd8..eb3953b6 100755 --- a/net/container/entrypoint.sh +++ b/net/container/entrypoint.sh @@ -18,5 +18,5 @@ if [ "$DEV" == "1" ]; then done else cd /app/databag/net/server - /usr/local/go/bin/go run databag -p 7000 -w /app/databag/net/web/build -s /var/lib/databag -t /opt/databag/transform + ./databag -p 7000 -w /app/databag/net/web/build -s /var/lib/databag -t /opt/databag/transform fi