feat: add docker build support
Some checks reported errors
gitea-sync/antos/pipeline/head This commit looks good
gitea-sync/antos/pipeline/tag Something is wrong with the build of this commit

This commit is contained in:
DanyLE 2024-03-10 23:10:05 +01:00
parent 8ef0a5b7db
commit 43347010a8
7 changed files with 112 additions and 38 deletions

16
Jenkinsfile vendored
View File

@ -79,6 +79,22 @@ pipeline {
'''
}
}
stage('Build docker') {
agent {
node { label'workstation' }
}
steps {
script {
if (env.TAG_NAME) {
sh'''
DOCKER_TAG=$TAG_NAME DOCKER_IMAGE=iohubdev/antos make docker
'''
} else {
echo "Regular commit doing nothing"
}
}
}
}
stage('Archive') {
steps {
script {

View File

@ -1,13 +1,16 @@
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TAG:=$(subst master,stable,$(subst refs/heads/,,$(shell git symbolic-ref -q HEAD)))
DOCKER_TAG?=$(subst master,stable,$(subst refs/heads/,,$(shell git symbolic-ref -q HEAD)))
DOCKER_IMAGE?=iohubdev/antos
ARCH?=amd64
VERSION?=2.0.0-b
RUSTUP_HOME?=/opt/rust
CARGO_HOME?=/opt/rust/cargo
DESTDIR?=$(ROOT_DIR)/build/
BUILDDIR?=$(ROOT_DIR)/build/
DESTDIR?=/
ifeq ('$(ARCH)','amd64')
RUST_TARGET?=x86_64-unknown-linux-gnu
@ -30,7 +33,7 @@ endif
CC:=$(CC_PREFIX)gcc
CXX:=$(CC_PREFIX)g++
BUILD_PREFIX:=/opt/www
INSTALL_DIR:=$(DESTDIR)/$(ARCH)/$(BUILD_PREFIX)
INSTALL_DIR:=$(BUILDDIR)/$(ARCH)/$(BUILD_PREFIX)
BUILDID:=$(shell git rev-parse --short HEAD)
@ -51,7 +54,7 @@ antd: httpd plugins luasec luasocket silk luafcgi
httpd: clean_c
cd $(ROOT_DIR)/antd/ant-http && libtoolize && aclocal && autoconf && automake --add-missing
cd $(ROOT_DIR)/antd/ant-http && ./configure $(HOST) --prefix=$(BUILD_PREFIX)
DESTDIR=$(DESTDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/ant-http install
DESTDIR=$(BUILDDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/ant-http install
plugins: antd-fcgi-plugin antd-tunnel-plugin antd-wvnc-plugin antd-tunnel-publishers
@echo "Finish making plugins"
@ -66,7 +69,7 @@ luasec: clean_c
make -C $(ROOT_DIR)/antd/luasec linux
CC=$(CC) \
INC_PATH=-I$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
DESTDIR=$(DESTDIR)/$(ARCH) \
DESTDIR=$(BUILDDIR)/$(ARCH) \
LUAPATH=/opt/www/lib/lua \
LUACPATH=/opt/www/lib/lua \
make -C $(ROOT_DIR)/antd/luasec install
@ -88,7 +91,7 @@ luasocket: clean_c
LUAINC_linux=$(ROOT_DIR)/antd/silk/modules/lua/lua54/ \
LUAPREFIX_linux=$(BUILD_PREFIX) \
PLAT=linux \
DESTDIR=$(DESTDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/luasocket install-unix
DESTDIR=$(BUILDDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/luasocket install-unix
-mkdir -p $(INSTALL_DIR)/lib/lua
cp -rf $(INSTALL_DIR)/lib/lua/5.4/* $(INSTALL_DIR)/lib/lua/
cp -rf $(INSTALL_DIR)/share/lua/5.4/* $(INSTALL_DIR)/lib/lua/
@ -99,7 +102,7 @@ antd-% sil%: clean_c
cd $(ROOT_DIR)/antd/$@ && libtoolize && aclocal && autoconf && automake --add-missing
cd $(ROOT_DIR)/antd/$@ && CFLAGS="-I$(INSTALL_DIR)/include" LDFLAGS="-L$(INSTALL_DIR)/lib" \
./configure $(HOST) --prefix=$(BUILD_PREFIX)
DESTDIR=$(DESTDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/$@ install
DESTDIR=$(BUILDDIR)/$(ARCH) make -C $(ROOT_DIR)/antd/$@ install
luafcgi:
ifeq ($(LUAFCGI_IGNORE),)
@ -128,6 +131,16 @@ clean_c:
-make -C antd/luasocket clean
-make -C antd/silk clean
install:
cd $(INSTALL_DIR) && find . -type f,l \
-exec install -Dm 755 "{}" "$(DESTDIR)/$(BUILD_PREFIX)/{}" \;
uninstall:
cd $(INSTALL_DIR) && find . -type f,l \
-exec rm "$(DESTDIR)/$(BUILD_PREFIX)/{}" \;
find $(DESTDIR)/$(BUILD_PREFIX) -type d -empty -delete
clean: clean_c
@echo "Clean Rust project and output DIR"
RUSTUP_HOME=$(RUSTUP_HOME) CARGO_HOME=$(CARGO_HOME) \
@ -136,7 +149,7 @@ clean: clean_c
cargo clean \
--manifest-path=$(ROOT_DIR)/antd/luafcgi/Cargo.toml \
--config=$(ROOT_DIR)/antd/luafcgi/.cargo/config.toml
-rm -rf $(DESTDIR)/*
-rm -rf $(BUILDDIR)/*
backend:
@echo "Building $@"
@ -153,15 +166,27 @@ else
endif
deb:
-rm $(DESTDIR)/$(ARCH)/*.deb
scripts/mkdeb.sh $(VERSION_STR) $(ARCH) $(DESTDIR)/$(ARCH)
-rm $(BUILDDIR)/$(ARCH)/*.deb
scripts/mkdeb.sh $(VERSION_STR) $(ARCH) $(BUILDDIR)/$(ARCH)
tar.gz: antos
-rm $(DESTDIR)/$(ARCH)/$(PKG_NAME).tar.gz
cd $(DESTDIR)/$(ARCH)/ && tar cvzf $(PKG_NAME).tar.gz opt
-rm $(BUILDDIR)/$(ARCH)/$(PKG_NAME).tar.gz
cd $(BUILDDIR)/$(ARCH)/ && tar cvzf $(PKG_NAME).tar.gz opt
appimg:
-rm $(DESTDIR)/$(ARCH)/*.AppImage
scripts/mkappimg.sh $(ARCH) $(VERSION_STR) $(DESTDIR)/$(ARCH) $(ROOT_DIR)/antos-64.png
-rm $(BUILDDIR)/$(ARCH)/*.AppImage
scripts/mkappimg.sh $(ARCH) $(VERSION_STR) $(BUILDDIR)/$(ARCH) $(ROOT_DIR)/antos-64.png
.PHONY: antd antos
docker:
ln -sfn arm $(BUILDDIR)/armv7l
ln -sfn arm64 $(BUILDDIR)/aarch64
ln -sfn amd64 $(BUILDDIR)/x86_64
docker buildx build \
--platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
--tag $(DOCKER_IMAGE):$(DOCKER_TAG) \
-f docker/antos/Dockerfile \
--push \
.
rm $(BUILDDIR)/aarch64 $(BUILDDIR)/armv7l $(BUILDDIR)/x86_64
# --push
.PHONY: antd antos docker

@ -1 +1 @@
Subproject commit 426ccca40447c366014104fd799f7a0efbb5de97
Subproject commit dd1ceec9965b2c9582ffa3a60419215c7eff0a98

@ -1 +1 @@
Subproject commit 32bd62ae865bfe730e940ca02fdebd92b8ab7090
Subproject commit 37f68f0e04aadf3e829eab7e6a6fe569e2e3032a

View File

@ -1,13 +1,11 @@
FROM debian:bookworm AS deploy-env
ARG tag
COPY deps/ /
RUN apt-get update && apt-get --yes --no-install-recommends install libsqlite3-0 zlib1g libreadline8 wget libssl3 libvncclient1 libturbojpeg0 openssh-client tar tree
RUN apt clean && rm -rf /var/lib/apt/lists/*
RUN mkdir /ulib
RUN cp -rf /lib/*-linux-*/libsqlite3*.so* /ulib
RUN cp -rf /lib/*-linux-*/libreadline*.so* /ulib
RUN cp -rf /lib/*-linux-*/libncurse*.so* /ulib
# RUN cp -rf /lib/*-linux-*/libncurse*.so* /ulib
RUN cp -rf /lib/*-linux-*/libz*.so* /ulib
RUN cp -rf /lib/*-linux-*/libcrypt*.so* /ulib
RUN cp -rf /lib/*-linux-*/libdl*.so* /ulib
@ -50,14 +48,10 @@ RUN cp -rf /lib/*-linux-*/libcom_err*.so* /ulib
RUN cp -rf /lib/*-linux-*/libkrb5support*.so* /ulib
RUN cp -rf /lib/*-linux-*/libkeyutils*.so* /ulib
# antos
RUN mkdir /build
COPY build/ /build/
RUN mkdir /platform
COPY antos-release/ /
RUN tar -xzf /build/$tag/AntOS_$(uname -m).tar.gz -C /platform/
RUN chown -R root:root /platform
RUN tree /platform
RUN ls -al /platform
RUN cp -rf /build/$(uname -m)/* /platform/
FROM busybox:1.36.1-glibc
#copy all necessary libraries
@ -66,18 +60,13 @@ COPY --from=deploy-env /bin/wget /bin/
COPY --from=deploy-env /usr/bin/ssh /bin/
COPY --from=deploy-env /usr/bin/ssh-keygen /bin/
COPY --from=deploy-env /usr/bin/ssh-copy-id /bin/
COPY bash /bin/bash
COPY profile /etc/profile
RUN chmod a+x /bin/bash
# copy backend
COPY --from=deploy-env /platform/ /
# copy frontend
COPY antd-config.ini /opt/www/antd-config.ini
COPY runner.ini /opt/www/runner.ini
RUN chmod 744 /opt/www/antd-config.ini
RUN chmod 744 /opt/www/runner.ini
COPY docker/antos/profile /etc/profile
COPY --from=deploy-env /platform/opt/ /lib/opt/
COPY start.sh /start.sh
COPY docker/antos/start.sh /start.sh
RUN chmod 700 /start.sh
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/www/lib/"
ENV PATH="$PATH:/opt/www/bin/"
# start the entry point
ENTRYPOINT /start.sh

23
docker/antos/profile Normal file
View File

@ -0,0 +1,23 @@
# unset variable if exists
unset ANTOS_USER
unset ANTOS_PASSWORD
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
export PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
export PATH="$HOME/.local/bin:$PATH"
fi
# set user private LIB search path
if [ -d "$HOME/lib" ] ; then
export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"
fi
# set user private LIB search path
if [ -d "$HOME/.local/lib" ] ; then
export LD_LIBRARY_PATH="$HOME/.local/lib:$LD_LIBRARY_PATH"
fi

21
docker/antos/start.sh Normal file
View File

@ -0,0 +1,21 @@
#! /bin/sh
if [ -f "/file.fs" ]; then
mount /file.fs /home
fi
if [ -n "$ANTOS_USER" ]; then
adduser --home "/home/$ANTOS_USER" --disabled-password --gecos "" "$ANTOS_USER"
echo "$ANTOS_USER:$ANTOS_PASSWORD" | /bin/chpasswd
fi
unset ANTOS_USER
unset ANTOS_PASSWORD
# start syslog
syslogd -O /tmp/message
antd /opt/www/etc/antd-config.ini &
sleep 2
runner /opt/www/etc/runner.ini &
cat