guix-docker-images/Dockerfile

83 lines
3.2 KiB
Docker
Raw Permalink Normal View History

2019-09-18 09:15:13 +02:00
# syntax = docker/dockerfile:1.1-experimental
2019-09-18 07:16:43 +02:00
#
# MetaCall Guix by Parra Studios
2020-10-29 21:30:45 +01:00
# Docker image for using Guix in a CI/CD environment.
2019-09-18 07:16:43 +02:00
#
2020-01-03 01:15:37 +01:00
# Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia <vic798@gmail.com>
2019-09-18 07:16:43 +02:00
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
FROM alpine:3.14 AS guix
2019-09-18 07:16:43 +02:00
# Image descriptor
LABEL copyright.name="Vicente Eduardo Ferrer Garcia" \
copyright.address="vic798@gmail.com" \
maintainer.name="Vicente Eduardo Ferrer Garcia" \
maintainer.address="vic798@gmail.com" \
vendor="MetaCall Inc." \
version="0.1"
2019-09-19 09:30:12 +02:00
ARG METACALL_GUIX_VERSION
ARG METACALL_GUIX_ARCH
# Copy entry point
COPY scripts/entry-point.sh /entry-point.sh
# Install Guix
2019-11-27 01:53:16 +01:00
RUN mkdir -p /gnu/store \
2019-09-18 07:16:43 +02:00
&& addgroup guixbuild \
&& addgroup guix-builder \
&& chgrp guix-builder -R /gnu/store \
2019-12-05 17:22:57 +01:00
&& chmod 1777 /gnu/store \
2019-09-18 07:16:43 +02:00
&& for i in `seq -w 1 10`; do \
2019-11-27 01:29:32 +01:00
adduser -G guixbuild -h /var/empty -s `which nologin` -S guixbuilder$i; \
2019-09-18 07:16:43 +02:00
done \
2019-09-19 09:30:12 +02:00
&& wget -O - https://ftp.gnu.org/gnu/guix/guix-binary-${METACALL_GUIX_VERSION}.${METACALL_GUIX_ARCH}-linux.tar.xz | tar -xJv -C / \
2019-09-20 15:42:20 +02:00
&& mkdir -p /root/.config/guix \
&& ln -sf /var/guix/profiles/per-user/root/current-guix /root/.config/guix/current \
2019-09-18 07:16:43 +02:00
&& mkdir -p /usr/local/bin \
&& ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix /usr/local/bin/ \
&& mkdir -p /usr/local/share/info \
&& for i in /var/guix/profiles/per-user/root/current-guix/share/info/*; do \
ln -s $i /usr/local/share/info/; \
done \
2019-11-27 01:53:16 +01:00
&& chmod +x /entry-point.sh \
&& source $GUIX_PROFILE/etc/profile \
&& guix archive --authorize < /root/.config/guix/current/share/guix/ci.guix.gnu.org.pub
ENV GUIX_PROFILE="/root/.config/guix/current" \
GUIX_LOCPATH="/root/.guix-profile/lib/locale/" \
LANG="en_US.UTF-8" \
SSL_CERT_DIR="/root/.guix-profile/etc/ssl/certs" \
SSL_CERT_FILE="/root/.guix-profile/etc/ssl/certs/ca-certificates.crt" \
GIT_SSL_FILE="/root/.guix-profile/etc/ssl/certs/ca-certificates.crt" \
GIT_SSL_CAINFO="/root/.guix-profile/etc/ssl/certs/ca-certificates.crt" \
CURL_CA_BUNDLE="/root/.guix-profile/etc/ssl/certs/ca-certificates.crt"
# Copy additional channels
COPY channels/ /root/.config/guix/
# Run pull (https://github.com/docker/buildx/blob/master/README.md#--allowentitlement)
# Restart with latest version of the daemon and garbage collect
RUN --security=insecure sh -c '/entry-point.sh guix pull && guix package --fallback -i glibc-utf8-locales nss-certs' \
2021-01-09 11:36:18 +01:00
&& sh -c '/entry-point.sh guix gc && guix gc --optimize'
# Verify if the certificates exist and the version is correct (it is fixed to the channels.scm)
RUN [ -e /root/.guix-profile/etc/ssl/certs/ca-certificates.crt ] \
&& [ "`cat /root/.config/guix/channels.scm | grep commit | cut -d'"' -f 2`" = "`guix --version | head -n 1 | awk '{print $NF}'`" ]
2019-09-18 07:16:43 +02:00
ENTRYPOINT ["/entry-point.sh"]
CMD ["sh"]