diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..7cd8cff --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,50 @@ +stages: +- build +- pack + +"build@main": + image: registry.gitlab.com/xsf/docker-images/registry-buildspace/image:0.1.0 + stage: build + script: + - make + rules: + - if: '$CI_COMMIT_REF_NAME =~ /^main$/' + when: always + - when: never + artifacts: + paths: + - registrar/ + expire_in: '1 day' + +"pack@main": + image: docker:19.03.11 + stage: pack + services: + - docker:19.03.11-dind + script: + - 'export IMAGE_REF="${CI_REGISTRY_IMAGE}/packed:main-$(date -Idate)-${CI_COMMIT_SHORT_SHA}"' + - 'export LATEST_REF="${CI_REGISTRY_IMAGE}/packed:main-latest"' + - 'docker build -t "$IMAGE_REF" -f pack-only.Dockerfile .' + - 'docker image tag "$IMAGE_REF" "$LATEST_REF"' + - 'docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY' + - 'docker push "$IMAGE_REF"' + - 'docker push "$LATEST_REF"' + rules: + - if: '$CI_COMMIT_REF_NAME =~ /^main$/' + when: on_success + - when: never + +"build@mr": + image: registry.gitlab.com/xsf/docker-images/registry-buildspace/image:0.1.0 + stage: build + script: + - make + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: always + - when: never + artifacts: + expose_as: "Content" + paths: + - registrar/ + expire_in: '1 day' diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index dc3db8a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM xmppxsf/registry-base:latest as build - -ARG NCORES=1 -ARG TARGETS="validate build" - -COPY *.xml *.xsl reg.dtd reg.ent Makefile /src/ - -WORKDIR /src -RUN OUTDIR=/var/www/html/registrar/ make -j$NCORES $TARGETS - -FROM nginx:1-alpine -COPY --from=build /var/www/html/registrar/ /usr/share/nginx/html/registar/ -RUN sed -ri '/root\s+\/usr\/share\/nginx\/html/s/^(.+)$/\1\nautoindex on;/' /etc/nginx/conf.d/default.conf - -EXPOSE 80 diff --git a/pack-only.Dockerfile b/pack-only.Dockerfile new file mode 100644 index 0000000..51274d3 --- /dev/null +++ b/pack-only.Dockerfile @@ -0,0 +1,5 @@ +FROM nginx:1-alpine +COPY registrar/ /usr/share/nginx/html/registar/ +RUN sed -ri '/root\s+\/usr\/share\/nginx\/html/s/^(.+)$/\1\nautoindex on;/' /etc/nginx/conf.d/default.conf + +EXPOSE 80