0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Raspberry Pi3でGiteaを動かしたい

0
Posted at

モチベーション

余っているRaspberry Pi3を、家用のGit Serverにしたい。

手順

公式Gitレポジトリのクローンを作成

git clone https://github.com/go-gitea/gitea

DockerfileのビルドをRaspberry Pi3で試みたが、JavaScript heap out of memoryで上手くいかないので断念。arm v6用のバイナリを利用するようにDockerfileを編集。

gitea/Dockerfile
#Build stage
FROM docker.io/library/golang:1.20-alpine3.18 AS build-env

ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}

ARG GITEA_VERSION
ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS "bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS

#Build deps
RUN apk --no-cache add build-base git nodejs npm

#Setup repo
COPY . ${GOPATH}/src/code.gitea.io/gitea
WORKDIR ${GOPATH}/src/code.gitea.io/gitea

#Checkout version if set
### Pi3ではビルドを完遂できないのでコメントアウト
# RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
#  && make clean-all build

# Begin env-to-ini build
RUN go build contrib/environment-to-ini/environment-to-ini.go

FROM docker.io/library/alpine:3.18
LABEL maintainer="maintainers@gitea.io"

EXPOSE 22 3000
# wgetとgpgのインストールを追加
RUN apk --no-cache add \
    bash \
    ca-certificates \
    curl \
    gettext \
    git \
    linux-pam \
    openssh \
    s6 \
    sqlite \
    su-exec \
    gnupg \
    wget \
    gpg

# armv6用のバイナリを取得
RUN set -eux; \
    wget -O gitea https://dl.gitea.com/gitea/main/gitea-main-linux-arm-6; \
    wget -O gitea-main-linux-arm-6.asc https://dl.gitea.com/gitea/main/gitea-main-linux-arm-6.asc; \
    gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2; \
    gpg --verify gitea-main-linux-arm-6.asc gitea; \
    mkdir -p /app/gitea; \
    cp gitea /app/gitea/

RUN addgroup \
    -S -g 1000 \
    git && \
  adduser \
    -S -H -D \
    -h /data/git \
    -s /bin/bash \
    -u 1000 \
    -G git \
    git && \
  echo "git:*" | chpasswd -e

ENV USER git
ENV GITEA_CUSTOM /data/gitea

VOLUME ["/data"]

ENTRYPOINT ["/usr/bin/entrypoint"]
CMD ["/bin/s6-svscan", "/etc/s6"]

COPY docker/root /
# バイナリはダウンロードで対応しているので削除
# COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
# 無いのでコメントアウト
# COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/*
# 無いのでコメントアウト
# RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh

公式ページを参考に、docker-compose.yamlを準備

gitea/docker-compose.yaml
version: "3"

networks:
  gitea:
    external: false

services:
  server:
    build:
      dockerfile: ./Dockerfile
    # image: gitea/gitea
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "80:3000"
      - "222:22"

    depends_on:
      - db

  db:
    image: postgres:14
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      - gitea
    volumes:
      - ./postgres:/var/lib/postgresql/data

ビルド

sudo docker compose build

実行

sudo docker compose up -d

うまくいった。
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?