From 6991e01310ca4ee23c668d57dd118166aa5528b9 Mon Sep 17 00:00:00 2001
From: drebs <drebs@riseup.net>
Date: Sun, 27 Jun 2021 13:33:48 -0300
Subject: [PATCH] Build an image with pelican

---
 .gitlab-ci.yml | 20 ++++++++++++++++++++
 Dockerfile     |  5 +++++
 2 files changed, 25 insertions(+)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 Dockerfile

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..8346b93
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,20 @@
+build:
+  image: docker:git
+  stage: build
+  tags:
+    - docker-dind
+  services:
+    - docker:dind
+  before_script:
+    - docker info
+    - IMAGE=${CI_REGISTRY}/pelican
+  script:
+    - docker build -t ${IMAGE}:latest .
+    - alpine_version=alpine-$( docker run --rm --entrypoint /bin/sh ${IMAGE}:latest -c 'cat /etc/alpine-release' )
+    - python_version=$( docker run --rm --entrypoint /usr/local/bin/python3 ${IMAGE}:latest --version | tr ' ' - )
+    - pelican_version=$( docker run --rm --entrypoint /usr/local/bin/pip3 ${IMAGE}:latest list | grep pelican | sed -e 's/ \+/-/' )
+    - TAG="$( ./common/image_tag.sh )_${alpine_version}_${python_version}_${pelican_version}"
+    - docker tag ${IMAGE}:latest ${IMAGE}:${TAG}
+    - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" ${CI_REGISTRY}
+    - 'echo "Pushing: ${IMAGE}:${TAG}"'
+    - docker push ${IMAGE}:${TAG}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..0b0a881
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,5 @@
+FROM python:alpine
+RUN pip3 install pelican[markdown]
+RUN mkdir /source
+ENTRYPOINT ["/usr/local/bin/pelican"]
+CMD ["/source"]
-- 
GitLab