alpinelinux / alpine-docker-gitlab

[MIRROR] Gitlab docker image based on Alpine Linux
https://gitlab.alpinelinux.org/alpine/infra/docker/gitlab
MIT License
14 stars 16 forks source link

15.11-stable, Restore unavailable #16

Open supar opened 1 year ago

supar commented 1 year ago

The entrypoint.sh script currently does not include any available restore methods. Having a restore method is essential for server migration purposes. If you attempt to perform a migration from a container using the shell command docker compose exec gitlab sh, you may encounter the following error:

Backup::Error: gitaly-backup binary not found and gitaly_backup_path is not configured

This error occurs because the GitLab main image does not include the gitaly_backup binary from the gitaly image, which is required for the restore process.

Please note that in the prepare_dirs() method, the following directories are also required for installation during the restore scenario:

/home/git/gitlab/shared/terraform_state
/home/git/gitlab/shared/packages
Ikke commented 1 year ago

I've never used the restore feature of gitlab, so I'd have to look into how to support that.

supar commented 1 year ago

I have a makeshift solution

Dockerfile

--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,9 @@
 ARG ALPINE_VERSION
 ARG RUBY_VERSION
 ARG GITLAB_SHELL_VERSION
+ARG GITALY_SERVER_VERSION
 FROM alpinelinux/gitlab-shell:${GITLAB_SHELL_VERSION} as gitlab-shell
+FROM alpinelinux/gitaly:${GITALY_SERVER_VERSION} as gitaly

 FROM ruby:$RUBY_VERSION-alpine$ALPINE_VERSION

@@ -10,6 +12,7 @@ ENV GITLAB_VERSION=$GITLAB_VERSION

 COPY overlay /
 COPY --from=gitlab-shell /home/git/gitlab-shell /home/git/gitlab-shell
+COPY --from=gitaly /usr/local/bin/gitaly-backup /usr/local/bin/gitaly-backup

 RUN setup.sh

Taskfile

--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -119,6 +119,7 @@ tasks:
     deps:
       - .build-args
       - build-gitlab-shell
+      - build-gitaly
       - deploy-libs-gitlab
     sources:
       - build-args.env
@@ -150,6 +151,7 @@ tasks:
       - build-args.env
       - gitaly/*
       - gitaly/**/*
+    run: once
     status:
       - docker image inspect {{.GITALY_IMAGE}}
   save-image-gitaly:

docker-compose.yml

--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -9,6 +9,7 @@ services:
         - RUBY_VERSION
         - GITLAB_VERSION
         - GITLAB_SHELL_VERSION
+        - GITALY_SERVER_VERSION
     hostname: ${GITLAB_HOSTNAME:-gitlab}
     restart: always
     ports:

But there is problem with tar utility. While gitlab restores data it fails

rake aborted!
Backup::Error: Restore operation failed: tar: unrecognized option: unlink-first
BusyBox v1.35.0 (2022-08-01 15:14:44 UTC) multi-call binary.

Usage: tar c|x|t [-ZzJjahmvokO] [-f TARFILE] [-C DIR] [-T FILE] [-X FILE] [LONGOPT]... [FILE]...

Create, extract, or list files from a tar file

    c   Create
    x   Extract
    t   List
...

But if install full version of tar (add to setup.sh)

# add runtime dependencies
apk add --no-cache --virtual .gitlab-runtime \
        tar \
        git \
...

than build image fails

#0 802.0 Extracting libxml2-2.10.4.tar.xz into
#0 802.0 tmp/x86_64-pc-linux-musl/ports/libxml2/2.10.4... ERROR, review
#0 802.0 '/usr/local/bundle/gems/nokogiri-1.14.3/ext/nokogiri/tmp/x86_64-pc-linux-musl/ports/libxml2/2.10.4/extract.log'
#0 802.0 to see what happened. Last lines are:
#0 802.0 ========================================================================
#0 802.0 tar (child): xz: Cannot exec: No such file or directory
#0 802.0 tar (child): Error is not recoverable: exiting now
#0 802.0 tar: Child returned status 2
#0 802.0 tar: Error is not recoverable: exiting now
#0 802.0 ========================================================================
#0 802.0 *** extconf.rb failed ***
#0 802.0 Could not create Makefile due to some reason, probably lack of necessary
#0 802.0 libraries and/or headers.  Check the mkmf.log file for more details.  You may
#0 802.0 need configuration options.
#0 802.0
#0 802.0 Provided configuration options:
#0 802.0    --with-opt-dir
#0 802.0    --without-opt-dir
#0 802.0    --with-opt-include

This is some kind of mystery. May be You know how to resolve this?

Ikke commented 1 year ago

You need to install xz as well to be able to unpack tar.xz

supar commented 1 year ago

Yes, it works