Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker multi-arch base #1985

Merged
merged 10 commits into from
Nov 16, 2017
Merged

Conversation

sapk
Copy link
Member

@sapk sapk commented Jun 16, 2017

This PR permit to have only one Dockerfile that is buildable on most platform (386,amd64,arm,arm64) since it will use a multi-arch image as a base.

For this to work, we need a multi-arch image (gitea/gitea-base) that can be published via make docker-multi-arch-push-manifest with default params (DOCKER_MANIFEST ?= docker/manifest/base.yml) by any one that have acces to docker hub gitea account.

For testing purpose you could use sapk/gitea-base as a base. (made with DOCKER_IMAGE=sapk/gitea make docker-multi-arch-push-manifest).

First part of #1615

@lunny lunny added the topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile label Jun 17, 2017
@lunny lunny added this to the 1.3.0 milestone Jun 17, 2017
@sapk
Copy link
Member Author

sapk commented Jul 4, 2017

For information on how it works :
docker/manifest/base.yml is a file describing a multi-arch image gitea/gitea-base:latest (uploaded to docker hub via manifest-tool cli). In this file, I define which real image to get based on running arch.

Now we only need one Dockerfile that use gitea/gitea-base as it base. When building this Dockerfile, docker will use the corresponding image for the arch it run on.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 4, 2017
@sapk
Copy link
Member Author

sapk commented Sep 3, 2017

Rebased & use sapk/gitea-base as base maintained by a simple script (trigerred by travis): https://github.com/sapk/dockerfiles/blob/master/gitea/build.sh.
When someone with rigth for gitea account on docker hub could setup the same, we could migrate on gitea/gitea-base after.

@lafriks
Copy link
Member

lafriks commented Oct 25, 2017

@go-gitea/owners anyone up for this or should we move this to 1.4?

@lunny
Copy link
Member

lunny commented Oct 26, 2017

I suppose to move it to 1.4

@tboerger
Copy link
Member

I don't believe that this will work like it is.

@lafriks lafriks modified the milestones: 1.3.0, 1.4.0 Oct 26, 2017
@sapk
Copy link
Member Author

sapk commented Oct 26, 2017

@tboerger what do you think is missing ?

@tboerger
Copy link
Member

@tboerger what do you think is missing ?

The schema simply looks wrong... You are just referencing base images...

@sapk
Copy link
Member Author

sapk commented Oct 26, 2017

@tboerger base image that is multi-arch so that you can build the same Dockerfile on any arch (arm, x64). This will not give a multi-arch image of gitea on docker hub but it is the first step and since my previous PR was a lot complicated, I split it into "small" steps and first one is to have one Dockerfile for all platform.

@sapk
Copy link
Member Author

sapk commented Oct 26, 2017

The best would be to run a script like https://github.com/sapk/dockerfiles/blob/master/gitea/build.sh (simply make docker-multi-arch-push-manifest when merged) with gitea docker hub creds to use gitea/gitea-base in place of sapk/gitea-base.

The next step is to build the image for each arch and use DOCKER_MANIFEST = docker/manifest/some_version.yml make docker-multi-arch-push-manifest to deliver a multi-arch image for gitea.

@sapk
Copy link
Member Author

sapk commented Oct 26, 2017

Rebase on master.

@sapk
Copy link
Member Author

sapk commented Oct 26, 2017

During the opening of this PR and now alpine base image is multi-arch so no need any more for custom multi-arch base. (7 hours ago ^^)

@sapk
Copy link
Member Author

sapk commented Oct 26, 2017

$ manifest-tool inspect alpine:3.6
Name:   alpine:3.6 (Type: application/vnd.docker.distribution.manifest.list.v2+json)
Digest: sha256:b40e202395eaec699f2d0c5e01e6d6cb8e6b57d77c0e0221600cf0b5940cf3ab
 * Contains 6 manifest references:
1    Mfst Type: application/vnd.docker.distribution.manifest.v2+json
1       Digest: sha256:a09e6318d74f23fe68bad84259fedf5e6ce02c38537336419ee5e9abe10aa2af
1  Mfst Length: 528
1     Platform:
1           -      OS: linux
1           - OS Vers: 
1           - OS Feat: []
1           -    Arch: amd64
1           - Variant: 
1           - Feature: 
1     # Layers: 1
         layer 1: digest = sha256:b56ae66c29370df48e7377c8f9baa744a3958058a766793f821dadcb144a4647

2    Mfst Type: application/vnd.docker.distribution.manifest.v2+json
2       Digest: sha256:2dd7795cbac6f8d9a7780611802d292eb09cdbf4c569b22f88ed7b7124b7c12f
2  Mfst Length: 735
2     Platform:
2           -      OS: linux
2           - OS Vers: 
2           - OS Feat: []
2           -    Arch: arm
2           - Variant: v6
2           - Feature: 
2     # Layers: 2
         layer 1: digest = sha256:0864efeeb5cb8dca4eb53e5d6fd38486daee80fa326fe36d1ad254f8fa6bb310
         layer 2: digest = sha256:3cda69762aee1588fa82aeabf1af6d6ad24f737cce1451fab2e0199849b1e12e

3    Mfst Type: application/vnd.docker.distribution.manifest.v2+json
3       Digest: sha256:4d398eec2867d7be55d6916d91d99670ead7d4c9cdd72b21439fcbf71a18f73e
3  Mfst Length: 735
3     Platform:
3           -      OS: linux
3           - OS Vers: 
3           - OS Feat: []
3           -    Arch: arm64
3           - Variant: v8
3           - Feature: 
3     # Layers: 2
         layer 1: digest = sha256:bb473f0ebc12fde1bd45c1bd3c46f2d3aab367b1b7739464771455b9972f7894
         layer 2: digest = sha256:75ff6b7ff3a208b8399e701e7ea1b7edbdc654c8c60d33c6f09a7803e2dda776

4    Mfst Type: application/vnd.docker.distribution.manifest.v2+json
4       Digest: sha256:ee813612f9d7710d730c4574e7d835983bce17517165ddca0fb8f0b21856d780
4  Mfst Length: 735
4     Platform:
4           -      OS: linux
4           - OS Vers: 
4           - OS Feat: []
4           -    Arch: 386
4           - Variant: 
4           - Feature: 
4     # Layers: 2
         layer 1: digest = sha256:ffe4428ef008913a7ec63449e4ad3aa536b26103943146a302591dfceb157d2f
         layer 2: digest = sha256:5f4fe786260f2bd2710289e7c9487b423cb252a691fa501759b0768516122869

5    Mfst Type: application/vnd.docker.distribution.manifest.v2+json
5       Digest: sha256:adfb9b0b46b636098c67c2bca218c18e62048e439b9cf5a07e3668c8de96971d
5  Mfst Length: 735
5     Platform:
5           -      OS: linux
5           - OS Vers: 
5           - OS Feat: []
5           -    Arch: ppc64le
5           - Variant: 
5           - Feature: 
5     # Layers: 2
         layer 1: digest = sha256:1e52418956f7d2a8ea35e8e6e3318fd08e005b27457d77868c225e7433bbfa02
         layer 2: digest = sha256:acf472f4e5bb7956ac20bb343b304e1d3de1f79160c0d158cccbe25980022d50

6    Mfst Type: application/vnd.docker.distribution.manifest.v2+json
6       Digest: sha256:b20b3fc6e3959f9c761137fcf81f97bd0a36fe9f3908f24fda679df630b840d6
6  Mfst Length: 735
6     Platform:
6           -      OS: linux
6           - OS Vers: 
6           - OS Feat: []
6           -    Arch: s390x
6           - Variant: 
6           - Feature: 
6     # Layers: 2
         layer 1: digest = sha256:d45fd9d3c4f188ab1f3a4bf6a9f5202b3f1577dbb998f5f28e82d192e0c1f0e7
         layer 2: digest = sha256:0e5978b6b34b3e943e0fd25dfb50991c0bad82a986cfdaa91c4de756431ba679

@sapk
Copy link
Member Author

sapk commented Oct 26, 2017

This PR is now very simple. I kept a separate Makfile for docker since next steps will add more tasks.

@codecov-io
Copy link

codecov-io commented Oct 26, 2017

Codecov Report

Merging #1985 into master will decrease coverage by 0.4%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1985      +/-   ##
==========================================
- Coverage   27.26%   26.85%   -0.41%     
==========================================
  Files          89       89              
  Lines       17640    17600      -40     
==========================================
- Hits         4809     4727      -82     
- Misses      12144    12187      +43     
+ Partials      687      686       -1
Impacted Files Coverage Δ
modules/process/manager.go 21.51% <0%> (-52.4%) ⬇️
modules/markup/html.go 46.24% <0%> (-5.2%) ⬇️
routers/api/v1/misc/markdown.go 78% <0%> (-3.67%) ⬇️
models/models.go 28.07% <0%> (-0.25%) ⬇️
models/issue_comment.go 30.43% <0%> (-0.17%) ⬇️
routers/api/v1/misc/version.go 0% <0%> (ø) ⬆️
models/issue_tracked_time.go 83.05% <0%> (+9.91%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c3e605...1f5c252. Read the comment docs.

@bkcsoft
Copy link
Member

bkcsoft commented Oct 29, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 29, 2017
@sapk sapk mentioned this pull request Nov 15, 2017
@lafriks
Copy link
Member

lafriks commented Nov 15, 2017

@sapk Can you resolve conflicts. Otherwise LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 15, 2017
serve as base for build docker image for most platform (386,amd64,arm,arm64)
@sapk
Copy link
Member Author

sapk commented Nov 16, 2017

@lafriks should be good

@lafriks lafriks merged commit dac0f14 into go-gitea:master Nov 16, 2017
@tboerger
Copy link
Member

tboerger commented Nov 16, 2017

This doesn't make any sense to me but I'm out of that. Have fun with it...

@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants