From dc065f42d1dd8ced05a65e661cbb4a1edc2c9825 Mon Sep 17 00:00:00 2001 From: Abdulrhmn Ghanem Date: Sat, 17 Sep 2022 10:19:01 +0200 Subject: [PATCH] Add `kitspace_dev_entrypoint` --- .dockerignore | 69 +++++++++++++++++++++ Dockerfile.gitea.dev | 6 +- docker/root/usr/bin/kitspace_dev_entrypoint | 24 +++++++ 3 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 docker/root/usr/bin/kitspace_dev_entrypoint diff --git a/.dockerignore b/.dockerignore index d7a81dd5d4daf..51f9a7e162f5c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,71 @@ Dockerfile* node_modules + +# .gitignore content +.git + +**/*.test + +modules/migration/bindata.go +modules/migration/bindata.go.hash +modules/options/bindata.go +modules/options/bindata.go.hash +modules/public/bindata.go +modules/public/bindata.go.hash +modules/templates/bindata.go +modules/templates/bindata.go.hash + +**/*.db +**/*.log + +gitea +gitea-vet +debug +integrations.test + +bin +dist +custom/* +!custom/conf +custom/conf/* +!custom/conf/app.example.ini +data +indexers +log +public/img/avatar +tests/integration/gitea-integration-* +tests/integration/indexers-* +tests/e2e/gitea-e2e-* +tests/e2e/indexers-* +tests/e2e/reports +tests/e2e/test-artifacts +tests/e2e/test-snapshots +tests/*.ini +node_modules +yarn.lock +yarn-error.log +npm-debug.log* +public/js +public/serviceworker.js +public/css +public/fonts +public/img/webpack +vendor +web_src/fomantic/node_modules +web_src/fomantic/build/* +!web_src/fomantic/build/semantic.js +!web_src/fomantic/build/semantic.css +!web_src/fomantic/build/themes +web_src/fomantic/build/themes/* +!web_src/fomantic/build/themes/default +web_src/fomantic/build/themes/default/assets/* +!web_src/fomantic/build/themes/default/assets/fonts +web_src/fomantic/build/themes/default/assets/fonts/* +!web_src/fomantic/build/themes/default/assets/fonts/icons.woff2 +!web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2 +VERSION +.air +.go-licenses + +# Make evidence files +.make_evidence diff --git a/Dockerfile.gitea.dev b/Dockerfile.gitea.dev index 229626b249683..6819247c5398c 100644 --- a/Dockerfile.gitea.dev +++ b/Dockerfile.gitea.dev @@ -30,10 +30,8 @@ RUN apk --no-cache add \ COPY . /go/src/code.gitea.io/gitea WORKDIR /go/src/code.gitea.io/gitea -#Remove .git because of -buildvcs and submodule issue -RUN rm -f .git - RUN npm install --no-save +RUN mkdir .go-licenses RUN make build # Begin env-to-ini build @@ -65,5 +63,5 @@ COPY docker/root / RUN mkdir -p /app/gitea RUN cp /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea RUN cp /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini -RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini +RUN chmod 755 /usr/bin/entrypoint /usr/bin/kitspace_dev_entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/* diff --git a/docker/root/usr/bin/kitspace_dev_entrypoint b/docker/root/usr/bin/kitspace_dev_entrypoint new file mode 100644 index 0000000000000..d1aa580b493ba --- /dev/null +++ b/docker/root/usr/bin/kitspace_dev_entrypoint @@ -0,0 +1,24 @@ +#!/bin/sh +# This is a workaround to fix the vcs error caused by mounting the gitea source directory +# into the container, in development, so we remove the `.git` dir but this will remove it +# from the host manchine too. To work around this, we move `.git` dir, then build gitea, then +# reset `.git` again. + +cleanup() { + # If the container gets killed before reseting the .git folder + # reset it in the clean up command. + [ ! -e ".git" ] && mv /tmp/git .git +} + +# Traps +trap 'cleanup' SIGTERM +trap 'cleanup' SIGINT +trap 'cleanup' SIGQUIT + +# Move the git folder before building and add it again. +( mv .git /tmp/git && make build && mv /tmp/git .git && cp gitea /app/gitea/ && /usr/bin/entrypoint ) & + +wait $! + +# run the clean up procedure if the one of the commands above fails. +cleanup