Go version updated to 1.12.9
[ta/caas-registry.git] / SPECS / registry.spec
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 %define COMPONENT registry
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 2.7.1
18 %define RPM_MINOR_VERSION 7
19 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
20 %define go_version 1.12.9
21
22 Name:           %{RPM_NAME}
23 Version:        %{RPM_MAJOR_VERSION}
24 Release:        %{RPM_MINOR_VERSION}%{?dist}
25 Summary:        Containers as a Service Registry component
26 License:        %{_platform_license} and Apache License and GNU Lesser General Public License v3.0 only and BSD 3-clause New or Revised License and MIT License and Common Development and Distribution License and BSD and GNU General Public License v2.0 only
27 URL:            https://github.com/docker/distribution
28 BuildArch:      x86_64
29 Vendor:         %{_platform_vendor} and docker/distribution unmodified
30 Source0:        %{name}-%{version}.tar.gz
31
32 Requires: docker-ce >= 18.09.2, rsync
33 BuildRequires: docker-ce-cli >= 18.09.2, xz
34
35 %description
36 This rpm contains the docker registry container and ansible for caas subsystem.
37 This container contains the registry service.
38
39 %prep
40 %autosetup
41
42 %build
43 # Building the container
44 docker build \
45   --network=host \
46   --no-cache \
47   --force-rm \
48   --build-arg HTTP_PROXY="${http_proxy}" \
49   --build-arg HTTPS_PROXY="${https_proxy}" \
50   --build-arg NO_PROXY="${no_proxy}" \
51   --build-arg http_proxy="${http_proxy}" \
52   --build-arg https_proxy="${https_proxy}" \
53   --build-arg no_proxy="${no_proxy}" \
54   --build-arg REGISTRY="%{version}" \
55   --build-arg go_version="%{go_version}" \
56   --tag %{COMPONENT}:%{IMAGE_TAG} \
57   %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build/%{COMPONENT}/
58
59 # Creating a new folder for the container tar file
60 mkdir -p %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/
61
62 # Save the container
63 docker save %{COMPONENT}:%{IMAGE_TAG} | xz -z -T2 > %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/%{COMPONENT}:%{IMAGE_TAG}.tar
64
65 # Remove container
66 docker rmi -f %{COMPONENT}:%{IMAGE_TAG}
67
68 %install
69 # at this point the version variable changes e.g.: from 2.7.1 to 2.7.1-100.el7.centos.akrainolite.x86_64
70 mkdir -p %{buildroot}/%{_caas_container_tar_path}
71 rsync -av %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/%{COMPONENT}:%{IMAGE_TAG}.tar %{buildroot}/%{_caas_container_tar_path}/
72
73 mkdir -p %{buildroot}/%{_playbooks_path}/
74 rsync -av ansible/playbooks/registry_pre_config.yaml %{buildroot}/%{_playbooks_path}/
75 rsync -av ansible/playbooks/registry.yaml %{buildroot}/%{_playbooks_path}/
76
77 mkdir -p %{buildroot}/%{_roles_path}/
78 rsync -av ansible/roles/registry_pre_config %{buildroot}/%{_roles_path}/
79 rsync -av ansible/roles/registry %{buildroot}/%{_roles_path}/
80
81 %files
82 %{_caas_container_tar_path}/%{COMPONENT}:%{IMAGE_TAG}.tar
83 %{_playbooks_path}/*
84 %{_roles_path}/*
85
86
87 %preun
88
89 %post
90 mkdir -p %{_postconfig_path}/
91 ln -sf %{_playbooks_path}/registry_pre_config.yaml %{_postconfig_path}/
92 ln -sf %{_playbooks_path}/registry.yaml %{_postconfig_path}/
93
94 %postun
95 if [ $1 -eq 0 ]; then
96     rm -f %{_postconfig_path}/registry_pre_config.yaml
97     rm -f %{_postconfig_path}/registry.yaml
98 fi
99
100 %clean
101 rm -rf ${buildroot}