go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.26k stars 5.51k forks source link

Build issue (cross-build) after moving to time/tzdata for timezone in docker #13070

Open gioboske opened 4 years ago

gioboske commented 4 years ago

Description

After changing the Dockerfile to use time/tzdata for timezone in docker (#12922), trying to cross-build the docker image for arm32 (host macOS, target linux/arm/v6 or v7) fails with the following error:

[...]
# code.gitea.io/gitea
time/tzdata.init.0: unresolved inter-package jump to time.registerLoadFromEmbeddedTZData(time) from time/tzdata
make: *** [Makefile:553: gitea] Error 2
The command '/bin/sh -c if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi  && make clean-all build' returned a non-zero code: 2
make: *** [build] Error 2

Oddly, the cross-compilation for arm64 raise no error and the resulting image is fully functional.

Not sure if the issue is related to the golang:1.15-alpine3.12 image used as build environment, if it is related to QEMU or if it is related to gitea itself.

Changing back the docker file by removing timetzdata from ENV TAGS (in the build environment image) and adding again the tzdata package to the final image seems to solve the issue.

It would be great to rely on a single Dockerfile both for native and cross-compilation, so to keep any docker image building as simple as docker build --platform xxxx/xxx --build-arg XXX -t image:tag gitea.

Thank you for your support!

bolet commented 4 years ago

QEMU is not the cause here.

I confirm this bug also happens when building :

Your workaround works in this case too (many thanks).

6543 commented 4 years ago

@techknowlogick any idear?

darcato commented 4 years ago

I can confirm this problem while building the image with an arm32 based QNAP nas. (TS-231P2).

jonim8or commented 3 years ago

I have this same problem when building on a raspberry pi 4 with raspbian (armv71, 32 bit). For me doing the reverse of #12922 makes the build work again

gioboske commented 3 years ago

I have this same problem when building on a raspberry pi 4 with raspbian (armv71, 32 bit). For me doing the reverse of #12922 makes the build work again

I basically agree with you, but I guess it would mean giving up the possibility to embed the timezone database into gitea, using the new package included in go1.15. However, I'm not really skilled on that, so maybe it is better to wait for the feedback of the gitea develop team...

6543 commented 3 years ago

I see two points: revert 12922 and/or fix arm x32 issue in go upstream

bolet commented 3 years ago

AFAIK, some docker images use the timezone of the host machine (via some clever /etc/x mappings) and avoid 800KB of overhead : https://golang.org/doc/go1.15#time/tzdata For ARM boards this can make a difference. I'd love to see build time options to chose the way timezone works in gitea.

gioboske commented 3 years ago

@bolet: so (just for my understanding, again sorry I'm not so skilled on that), your proposal would be to support different options, such as:

option 1 (avoiding 800KB overhead)

option 2 (timezone db in docker image)

option 3 (embedding the timezone database at build time)

Is my understanding correct?

bolet commented 3 years ago

@gioboske Yes, I think you summed it all pretty well.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

OCram85 commented 3 years ago

Damn, #12922 killed the simplest way to build gitea loacally on a arm7 (armhf) based Raspi 4. Up to this point it was really simple to buld the temporary disabled arm7 build:

version: "3.3"
services:
  gitea:
    container_name: gitea
    build:
      context: https://github.com/go-gitea/gitea.git#release/v1.12
    image: ocram85/gitea:1.12 
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=postgres
      - DB_HOST=gitea_db:5432
      - DB_NAME=1234
      - DB_USER=g123434
      - DB_PASSWD=gitea
    restart: unless-stopped
    depends_on:
      - gitea_db
    volumes:
      - ./volumes/gitea/data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
...
...