[fusion_builder_container hundred_percent="no" hundred_percent_height="no" hundred_percent_height_scroll="no" hundred_percent_height_center_content="yes" equal_height_columns="no" menu_anchor="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" status="published" publish_date="" class="" id="" background_color="" background_image="" background_position="center center" background_repeat="no-repeat" fade="no" background_parallax="none" enable_mobile="no" parallax_speed="0.3" video_mp4="" video_webm="" video_ogv="" video_url="" video_aspect_ratio="16:9" video_loop="yes" video_mute="yes" video_preview_image="" border_size="" border_color="" border_style="solid" margin_top="" margin_bottom="" padding_top="" padding_right="" padding_bottom="" padding_left="" admin_label="Introduction" admin_toggled="yes"][fusion_builder_row][fusion_builder_column type="1_2" layout="1_2" spacing="" center_content="no" link="" target="_self" min_height="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" background_color="" background_image="" background_image_id="" background_position="left top" background_repeat="no-repeat" hover_type="none" border_size="0" border_color="" border_style="solid" border_position="all" border_radius="" box_shadow="no" dimension_box_shadow="" box_shadow_blur="0" box_shadow_spread="0" box_shadow_color="" box_shadow_style="" padding_top="" padding_right="" padding_bottom="" padding_left="" margin_top="" margin_bottom="" animation_type="" animation_direction="left" animation_speed="0.3" animation_offset="" last="no"][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Gitlab fait partie des logiciels d'hébergement git de référence pour garder une maîtrise du versionning des projets en interne.
Nous allons voir dans cet article comment rajouter à votre Gitlab la fonction registre Docker qui permet de stocker vos images docker locales dans vos projets git sur la même plateforme.
[/fusion_text][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Prérequis
Une installation de gitlab fonctionnelle, on conseille la version Omnibus permettant d'avoir une installation fonctionnelle rapidement.
Un fonctionnement en https.
Un certificat et un vhost dédié, le registre sera accessible sur une autre url que celle de gitlab.
Dans notre exemple :
https://gitlab.aukfood.org : le gitlab
https://registre.aukfood.org : le registre
[/fusion_text][/fusion_builder_column][fusion_builder_column type="1_2" layout="1_2" spacing="" center_content="no" link="" target="_self" min_height="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" background_color="" background_image="" background_image_id="" background_position="left top" background_repeat="no-repeat" hover_type="none" border_size="0" border_color="" border_style="solid" border_position="all" border_radius="" box_shadow="no" dimension_box_shadow="" box_shadow_blur="0" box_shadow_spread="0" box_shadow_color="" box_shadow_style="" padding_top="" padding_right="" padding_bottom="" padding_left="" margin_top="" margin_bottom="" animation_type="" animation_direction="left" animation_speed="0.3" animation_offset="" last="no"][fusion_content_boxes layout="icon-with-title" columns="1" title_size="" heading_size="2" title_color="" body_color="#000000" backgroundcolor="rgba(244,67,54,0)" icon="" iconflip="" iconrotate="" iconspin="no" iconcolor="" icon_circle="" icon_circle_radius="" circlecolor="" circlebordersize="" circlebordercolor="" outercirclebordersize="" outercirclebordercolor="" icon_size="" icon_hover_type="" hover_accent_color="" image="" image_id="" image_max_width="" link_type="" button_span="" link_area="" link_target="" icon_align="left" animation_type="" animation_delay="" animation_offset="" animation_direction="left" animation_speed="0.3" margin_top="" margin_bottom="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""][fusion_content_box title="Mise à jour de l'article" backgroundcolor="rgba(244,67,54,0.77)" icon="" iconflip="" iconrotate="" iconspin="no" iconcolor="" circlecolor="" circlebordersize="" circlebordercolor="" outercirclebordersize="" outercirclebordercolor="" image="" image_id="" image_max_width="" link="" linktext="Read More" link_target="" animation_type="" animation_direction="left" animation_speed="0.3" animation_offset=""]
Petite modification de cet article le 14 Août 2019 après des problèmes sur le push d'images avec l'erreur :
unknown blob
Cette erreur était due à un problème entre le proxy Apache et Gitlab lors de la transmission des en-têtes https :
RequestHeader set X-Forwarded-Proto "https"
[/fusion_content_box][/fusion_content_boxes][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent="no" hundred_percent_height="no" hundred_percent_height_scroll="no" hundred_percent_height_center_content="yes" equal_height_columns="no" menu_anchor="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" status="published" publish_date="" class="" id="" background_color="" background_image="" background_position="center center" background_repeat="no-repeat" fade="no" background_parallax="none" enable_mobile="no" parallax_speed="0.3" video_mp4="" video_webm="" video_ogv="" video_url="" video_aspect_ratio="16:9" video_loop="yes" video_mute="yes" video_preview_image="" border_size="" border_color="" border_style="solid" margin_top="" margin_bottom="" padding_top="" padding_right="" padding_bottom="" padding_left="" admin_label="Mise en place" admin_toggled="yes"][fusion_builder_row][fusion_builder_column type="1_1" layout="1_1" spacing="" center_content="no" link="" target="_self" min_height="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" background_color="" background_image="" background_image_id="" background_position="left top" background_repeat="no-repeat" hover_type="none" border_size="0" border_color="" border_style="solid" border_position="all" border_radius="" box_shadow="no" dimension_box_shadow="" box_shadow_blur="0" box_shadow_spread="0" box_shadow_color="" box_shadow_style="" padding_top="" padding_right="" padding_bottom="" padding_left="" margin_top="" margin_bottom="" animation_type="" animation_direction="left" animation_speed="0.3" animation_offset="" last="no"][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Configuration
Activer le registre dans le fichier /etc/gitlab/gitlab.rb
registry_external_url 'https://registre.aukfood.org'
Faire en sorte que ce soit à l'utilisateur du projet d'activer ou non le registre, cela évite de mettre en place du registre pour tout les projets, attention valable uniquement pour les nouveaux projets :
gitlab_rails['gitlab_default_projects_features_container_registry'] = false
Si besoins, changer le chemin de stockage des images :
gitlab_rails['registry_path'] = "/path/to/registry/storage"
Attention, ce répertoire doit être accessible par l'utilisateur faisant tourner gitlab et par apache.
Reconfigurer et redémarrer gitlab :
[/fusion_text][fusion_syntax_highlighter theme="" language="x-sh" line_numbers="" line_wrapping="" copy_to_clipboard="" copy_to_clipboard_text="Copy to Clipboard" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" font_size="" border_size="" border_color="" border_style="" background_color="" line_number_background_color="" line_number_text_color="" margin_top="" margin_left="" margin_bottom="" margin_right=""]Z2l0bGFiLWN0bCByZWNvbmZpZ3VyZQpnaXRsYWItY3RsIHJlc3RhcnQ=[/fusion_syntax_highlighter][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Activer le registre sur un projet
Vu qu'il à été défini que par défaut le registre était inactivé à la création des projets, il faudra l'activer pour chaque projet dans Settings / General / Permissions
[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent="no" hundred_percent_height="no" hundred_percent_height_scroll="no" hundred_percent_height_center_content="yes" equal_height_columns="no" menu_anchor="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" status="published" publish_date="" class="" id="" background_color="" background_image="" background_position="center center" background_repeat="no-repeat" fade="no" background_parallax="none" enable_mobile="no" parallax_speed="0.3" video_mp4="" video_webm="" video_ogv="" video_url="" video_aspect_ratio="16:9" video_loop="yes" video_mute="yes" video_preview_image="" border_size="" border_color="" border_style="solid" margin_top="" margin_bottom="" padding_top="" padding_right="" padding_bottom="" padding_left="" admin_label="Vhost Apache" admin_toggled="yes"][fusion_builder_row][fusion_builder_column type="1_1" layout="1_1" spacing="" center_content="no" link="" target="_self" min_height="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" background_color="" background_image="" background_image_id="" background_position="left top" background_repeat="no-repeat" hover_type="none" border_size="0" border_color="" border_style="solid" border_position="all" border_radius="" box_shadow="no" dimension_box_shadow="" box_shadow_blur="0" box_shadow_spread="0" box_shadow_color="" box_shadow_style="" padding_top="" padding_right="" padding_bottom="" padding_left="" margin_top="" margin_bottom="" animation_type="" animation_direction="left" animation_speed="0.3" animation_offset="" last="no"][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Vhost Apache
Créer un vhost Apache qui servira de proxy pour accéder à la fonction registre de gitlab par défaut sur le port 5000.
[/fusion_text][fusion_syntax_highlighter theme="" language="x-sh" line_numbers="" line_wrapping="" copy_to_clipboard="" copy_to_clipboard_text="Copy to Clipboard" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" font_size="" border_size="" border_color="" border_style="" background_color="" line_number_background_color="" line_number_text_color="" margin_top="" margin_left="" margin_bottom="" margin_right=""]PFZpcnR1YWxIb3N0ICo6ODA+CiAgU2VydmVyTmFtZSByZWdpc3RyZS5hdWtmb29kLm9yZwogIFJlZGlyZWN0IC8gaHR0cHM6Ly9yZWdpc3RyZS5hdWtmb29kLm9yZy8KPC9WaXJ0dWFsSG9zdD4KPFZpcnR1YWxIb3N0ICo6NDQzPgogIFNlcnZlck5hbWUgcmVnaXN0cmUuYXVrZm9vZC5vcmcKCiAgTG9nTGV2ZWwgd2FybgogIEVycm9yTG9nICJ8L3Vzci9iaW4vcm90YXRlbG9ncyAtbGMgL3Zhci9sb2cvYXBhY2hlMi9lcnJvcl9yZWdpc3RyZWxhYi4lWS4lbS4lZCA4NjQwMCIKICBDdXN0b21Mb2cgInwvdXNyL2Jpbi9yb3RhdGVsb2dzIC1sYyAvdmFyL2xvZy9hcGFjaGUyL2FjY2Vzc19yZWdpc3RyZWxhYi4lWS4lbS4lZCA4NjQwMCIgY29tYmluZWQKCiAgU1NMRW5naW5lIG9uCiAgU1NMQ2VydGlmaWNhdGVGaWxlIC9ldGMvbGV0c2VuY3J5cHQvbGl2ZS9yZWdpc3RyZS5hdWtmb29kLm9yZy9jZXJ0LnBlbQogIFNTTENlcnRpZmljYXRlS2V5RmlsZSAvZXRjL2xldHNlbmNyeXB0L2xpdmUvcmVnaXN0cmUuYXVrZm9vZC5vcmcvcHJpdmtleS5wZW0KICBTU0xDZXJ0aWZpY2F0ZUNoYWluRmlsZSAvZXRjL2xldHNlbmNyeXB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DMy1TSEE6RUNESEUtUlNBLURFUy1DQkMzLVNIQTpFREgtUlNBLURFUy1DQkMzLVNIQTpBRVMxMjgtR0NNLVNIQTI1NjpBRVMyNTYtR0NNLVNIQTM4NDpBRVMxMjgtU0hBMjU2OkFFUzI1Ni1TSEEyNTY6QUVTMTI4LVNIQTpBRVMyNTYtU0hBOkRFUy1DQkMzLVNIQTohRFNTClNTTEhvbm9yQ2lwaGVyT3JkZXIgICAgIG9uClNTTENvbXByZXNzaW9uICAgICAgICAgIG9mZgoKIyBPQ1NQIFN0YXBsaW5nLCBvbmx5IGluIGh0dHBkIDIuMy4zIGFuZCBsYXRlcgpTU0xVc2VTdGFwbGluZyAgICAgICAgICBvZmYKU1NMU3RhcGxpbmdSZXNwb25kZXJUaW1lb3V0IDUKU1NMU3RhcGxpbmdSZXR1cm5SZXNwb25kZXJFcnJvcnMgb2ZmClNTTFN0YXBsaW5nQ2FjaGUgICAgICAgIHNobWNiOi92YXIvcnVuL29jc3AoMTI4MDAwKQ==[/fusion_syntax_highlighter][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent="no" hundred_percent_height="no" hundred_percent_height_scroll="no" hundred_percent_height_center_content="yes" equal_height_columns="no" menu_anchor="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" status="published" publish_date="" class="" id="" background_color="" background_image="" background_position="center center" background_repeat="no-repeat" fade="no" background_parallax="none" enable_mobile="no" parallax_speed="0.3" video_mp4="" video_webm="" video_ogv="" video_url="" video_aspect_ratio="16:9" video_loop="yes" video_mute="yes" video_preview_image="" border_size="" border_color="" border_style="solid" margin_top="" margin_bottom="" padding_top="" padding_right="" padding_bottom="" padding_left="" admin_label="Utiliser le registre"][fusion_builder_row][fusion_builder_column type="1_1" layout="1_1" spacing="" center_content="no" link="" target="_self" min_height="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" background_color="" background_image="" background_image_id="" background_position="left top" background_repeat="no-repeat" hover_type="none" border_size="0" border_color="" border_style="solid" border_position="all" border_radius="" box_shadow="no" dimension_box_shadow="" box_shadow_blur="0" box_shadow_spread="0" box_shadow_color="" box_shadow_style="" padding_top="" padding_right="" padding_bottom="" padding_left="" margin_top="" margin_bottom="" animation_type="" animation_direction="left" animation_speed="0.3" animation_offset="" last="no"][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Utiliser le registre
Se connecter au registre
[/fusion_text][fusion_syntax_highlighter theme="" language="x-sh" line_numbers="" line_wrapping="" copy_to_clipboard="" copy_to_clipboard_text="Copy to Clipboard" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" font_size="" border_size="" border_color="" border_style="" background_color="" line_number_background_color="" line_number_text_color="" margin_top="" margin_left="" margin_bottom="" margin_right=""]ZG9ja2VyIGxvZ2luIHJlZ2lzdHJlLmF1a2Zvb2Qub3Jn[/fusion_syntax_highlighter][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Construire une image pour ce registre
[/fusion_text][fusion_syntax_highlighter theme="" language="x-sh" line_numbers="" line_wrapping="" copy_to_clipboard="" copy_to_clipboard_text="Copy to Clipboard" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" font_size="" border_size="" border_color="" border_style="" background_color="" line_number_background_color="" line_number_text_color="" margin_top="" margin_left="" margin_bottom="" margin_right=""]ZG9ja2VyIGJ1aWxkIC10IHJlZ2lzdHJlLmF1a2Zvb2Qub3JnL21lc3Byb2pldHMvbXlhcHA6MC4xIC4=[/fusion_syntax_highlighter][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Pousser une image sur le registre
[/fusion_text][fusion_syntax_highlighter theme="" language="x-sh" line_numbers="" line_wrapping="" copy_to_clipboard="" copy_to_clipboard_text="Copy to Clipboard" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" font_size="" border_size="" border_color="" border_style="" background_color="" line_number_background_color="" line_number_text_color="" margin_top="" margin_left="" margin_bottom="" margin_right=""]ZG9ja2VyIHB1c2ggcmVnaXN0cmUuYXVrZm9vZC5vcmcvbWVzcHJvamV0cy9teWFwcDowLjE=[/fusion_syntax_highlighter][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
Récupérer l'image
[/fusion_text][fusion_syntax_highlighter theme="" language="x-sh" line_numbers="" line_wrapping="" copy_to_clipboard="" copy_to_clipboard_text="Copy to Clipboard" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" font_size="" border_size="" border_color="" border_style="" background_color="" line_number_background_color="" line_number_text_color="" margin_top="" margin_left="" margin_bottom="" margin_right=""]ZG9ja2VyIGltYWdlIHB1bGwgcmVnaXN0cmUuYXVrZm9vZC5vcmcvbWVzcHJvamV0cy9teWFwcDowLjE=[/fusion_syntax_highlighter][fusion_text columns="" column_min_width="" column_spacing="" rule_style="default" rule_size="" rule_color="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id=""]
A suivre
Votre Gitlab est maintenant transformé en registre Docker.
[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]