Go version updated to 1.12.9
[ta/caas-registry.git] / docker-build / registry / Dockerfile
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 FROM alpine:3.9
16 MAINTAINER Balint Varga <balint.varga@nokia.com>
17
18 ARG REGISTRY
19 ENV REGISTRY_VERSION=$REGISTRY
20 ARG go_install_dir="/usr/local/go"
21 ARG go_version
22 ENV GOPATH /build
23 ENV PATH $go_install_dir/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
24
25 ENV DOCKER_BUILDTAGS include_oss include_gcs
26
27 COPY common_scripts/wait-for-files /usr/bin/
28 COPY mainstart.sh /
29
30 RUN adduser -u 149 -D -H -s /sbin/nologin dockerreg \
31 &&  chmod +x /mainstart.sh /usr/bin/wait-for-files \
32 \
33 &&  apk add --no-cache --virtual .build-deps build-base go godep git curl tar bash \
34 &&  mkdir -p $go_install_dir \
35 &&  curl -fsSL -k https://dl.google.com/go/go${go_version}.src.tar.gz | tar zx --strip-components=1 -C ${go_install_dir} \
36 &&  cd ${go_install_dir}/src/ \
37 &&  ./make.bash \
38 &&  mkdir -p ${GOPATH}/src/github.com/docker/distribution \
39 &&  curl -fsSL -k https://github.com/docker/distribution/archive/v${REGISTRY_VERSION}.tar.gz | tar zx --strip-components=1 -C ${GOPATH}/src/github.com/docker/distribution \
40 &&  cd ${GOPATH}/src/github.com/docker/distribution \
41 &&  go get -d -v \
42 &&  make PREFIX=/build clean binaries \
43 &&  mv ${GOPATH}/src/github.com/docker/distribution/bin/registry /usr/bin/ \
44 \
45 &&  apk del .build-deps \
46 &&  rm -rf $go_install_dir \
47 &&  rm -rf /build
48
49 WORKDIR /
50 ENTRYPOINT ["/mainstart.sh"]