diff --git a/.gitignore b/.gitignore index 34003fc..da7702a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ sql_app.db # C extensions *.so +# Skyline console +skyline_console + # Distribution / packaging .Python build/ @@ -73,7 +76,6 @@ venv.bak/ /log/ tmp/ test_results.html -skyline-console-* nginx.conf mypy-report/ doc/build diff --git a/Makefile b/Makefile index d9001a3..e61b4c7 100644 --- a/Makefile +++ b/Makefile @@ -62,9 +62,20 @@ endif .PHONY: clean clean: - rm -rf .venv dist htmlcov .coverage log test_results.html build .tox skyline_apiserver.egg-info AUTHORS ChangeLog + rm -rf .venv dist htmlcov .coverage log test_results.html build .tox skyline_apiserver.egg-info AUTHORS ChangeLog skyline_console +skyline_console: + mkdir skyline_console + +skyline_console/skyline_console.tar.gz: | skyline_console + wget -O $@ $(SKYLINE_CONSOLE_PACKAGE_URL) + +skyline_console/commit_id: skyline_console/skyline_console.tar.gz + commit_id_file="$$(tar tzf $< | grep -P '/commit_id\.txt$$')" \ + && tar xzf $< --directory skyline_console "$${commit_id_file}" \ + && mv "skyline_console/$${commit_id_file}" $@ + .PHONY: build devbuild BUILD_ENGINE ?= docker BUILD_CONTEXT ?= . @@ -78,26 +89,20 @@ else ifeq ($(BUILD_ENGINE), buildah) else $(error Unsupported build engine $(BUILD_ENGINE)) endif -build: - GIT_CONSOLE_COMMIT=$(shell rm -rf skyline-console-master.tar.gz && wget $(SKYLINE_CONSOLE_PACKAGE_URL) && tar -zxf skyline-console-master.tar.gz && cat skyline-console-*/skyline_console/static/commit_id.txt); \ +build: skyline_console/skyline_console.tar.gz skyline_console/commit_id $(build_cmd) --no-cache --pull --force-rm \ - --build-arg SKYLINE_CONSOLE_PACKAGE_URL=$(SKYLINE_CONSOLE_PACKAGE_URL) \ - --build-arg GIT_CONSOLE_COMMIT=$$GIT_CONSOLE_COMMIT \ + --build-arg GIT_CONSOLE_COMMIT=$(file < skyline_console/commit_id) \ --build-arg GIT_BRANCH=$(GIT_BRANCH) \ --build-arg GIT_COMMIT=$(GIT_COMMIT) \ --build-arg RELEASE_VERSION=$(RELEASE_VERSION) \ $(BUILD_ARGS) -f $(DOCKER_FILE) -t $(IMAGE):$(IMAGE_TAG) $(BUILD_CONTEXT) - rm -rf skyline-console-* -devbuild: - GIT_CONSOLE_COMMIT=$(shell rm -rf skyline-console-master.tar.gz && wget $(SKYLINE_CONSOLE_PACKAGE_URL) && tar -zxf skyline-console-master.tar.gz && cat skyline-console-*/skyline_console/static/commit_id.txt); \ +devbuild: skyline_console/skyline_console.tar.gz skyline_console/commit_id $(build_cmd) \ - --build-arg SKYLINE_CONSOLE_PACKAGE_URL=$(SKYLINE_CONSOLE_PACKAGE_URL) \ - --build-arg GIT_CONSOLE_COMMIT=$$GIT_CONSOLE_COMMIT \ + --build-arg GIT_CONSOLE_COMMIT=$(file < skyline_console/commit_id) \ --build-arg GIT_BRANCH=devbuild \ --build-arg GIT_COMMIT=devbuild \ --build-arg RELEASE_VERSION=devbuild \ $(BUILD_ARGS) -f $(DOCKER_FILE) -t $(IMAGE):$(IMAGE_TAG) $(BUILD_CONTEXT) - rm -rf skyline-console-* .PHONY: db_revision diff --git a/container/Dockerfile b/container/Dockerfile index 46b01fd..edfd9ee 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -1,7 +1,6 @@ FROM ubuntu:20.04 -ARG SKYLINE_CONSOLE_PACKAGE_URL ARG GIT_CONSOLE_COMMIT ARG GIT_BRANCH ARG GIT_COMMIT @@ -18,9 +17,11 @@ ENV LC_ALL C.UTF-8 RUN apt-get update -y && apt-get install -y --no-install-recommends apt-utils \ && DEBIAN_FRONTEND=noninteractive apt-get install -y \ gcc make nginx traceroute lsof iputils-ping vim git wget curl locales-all ssl-cert \ - python3 python3-pip python3-dev python3-venv python-dev-is-python3 \ - && mkdir -p /etc/skyline /var/log/skyline /var/lib/skyline \ - && pip install -U ${SKYLINE_CONSOLE_PACKAGE_URL} + python3 python3-pip python3-dev python3-venv python-dev-is-python3 + +COPY ./skyline_console /var/cache/skyline_apiserver/skyline_console + +RUN pip install -U /var/cache/skyline_apiserver/skyline_console/skyline_console.tar.gz COPY ./requirements.txt /skyline-apiserver/requirements.txt @@ -31,7 +32,8 @@ COPY ./ /skyline-apiserver/ RUN git init /skyline-apiserver \ && pip install skyline-apiserver/ -chttps://releases.openstack.org/constraints/upper/master \ && apt-get clean \ - && rm -rf ~/.cache/pip + && rm -rf ~/.cache/pip \ + && mkdir -p /etc/skyline /var/log/skyline /var/lib/skyline COPY ./etc/gunicorn.py /etc/skyline/gunicorn.py COPY ./etc/skyline.yaml.sample /etc/skyline/skyline.yaml