Skip to content

Commit ff6b8fc

Browse files
added docker containers to dockerfiles
1 parent f008ddb commit ff6b8fc

File tree

8 files changed

+417
-2
lines changed

8 files changed

+417
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ ENV TEST_HOME /home/testuser
113113
RUN groupadd -g ${gid} ${group} \
114114
&& useradd -d "$TEST_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user}
115115
RUN chown -R ${user} "$TEST_HOME"
116-
#RUN chown -R ${user} "/usr/src"
116+
RUN chown -R ${user} "/usr/src"
117117
USER ${user}
118118
```
119119

@@ -138,4 +138,4 @@ docker build . --tag image \
138138

139139
## TODO
140140

141-
- [] Fix Renovate
141+
- [] Fix Renovate

dockerfiles/Dockerfile.go.task

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:1.14 as builder
2+
ADD . /go/src/github.com/telia-oss/github-pr-resource
3+
WORKDIR /go/src/github.com/telia-oss/github-pr-resource
4+
RUN curl -sL https://taskfile.dev/install.sh | sh
5+
RUN ./bin/task build
6+
7+
FROM alpine:3.11 as resource
8+
COPY --from=builder /go/src/github.com/telia-oss/github-pr-resource/build /opt/resource
9+
RUN apk add --update --no-cache \
10+
git \
11+
openssh \
12+
&& chmod +x /opt/resource/*
13+
COPY scripts/askpass.sh /usr/local/bin/askpass.sh
14+
ADD scripts/install_git_crypt.sh install_git_crypt.sh
15+
RUN ./install_git_crypt.sh && rm ./install_git_crypt.sh
16+
17+
FROM resource
18+
LABEL MAINTAINER=telia-oss

dockerfiles/Dockerfile.renovate

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
ARG IMAGE=latest
2+
3+
# Base image
4+
#============
5+
FROM renovate/yarn:1.22.4@sha256:6f559c0e98e931b0650e35418d385f13726244ec20b4dac6de3dfa808ad49319 AS base
6+
7+
LABEL maintainer="Rhys Arkins <[email protected]>"
8+
LABEL name="renovate"
9+
LABEL org.opencontainers.image.source="https://github.com/renovatebot/renovate" \
10+
org.opencontainers.image.url="https://renovatebot.com" \
11+
org.opencontainers.image.licenses="AGPL-3.0-only"
12+
13+
USER root
14+
WORKDIR /usr/src/app/
15+
16+
# Build image
17+
#============
18+
FROM base as tsbuild
19+
20+
# Python 3 and make are required to build node-re2
21+
RUN apt-get update && apt-get install -y python3-minimal build-essential
22+
# force python3 for node-gyp
23+
RUN rm -rf /usr/bin/python && ln /usr/bin/python3 /usr/bin/python
24+
25+
COPY package.json .
26+
COPY yarn.lock .
27+
COPY tools tools
28+
RUN yarn install --frozen-lockfile
29+
30+
COPY lib lib
31+
COPY tsconfig.json tsconfig.json
32+
COPY tsconfig.app.json tsconfig.app.json
33+
34+
35+
RUN yarn build:docker
36+
37+
# Prune node_modules to production-only so they can be copied into the final image
38+
39+
RUN yarn install --production --frozen-lockfile
40+
41+
42+
# Final-base image
43+
#============
44+
FROM base as final-base
45+
46+
# Docker client and group
47+
48+
RUN groupadd -g 999 docker
49+
RUN usermod -aG docker ubuntu
50+
51+
# renovate: datasource=docker depName=docker versioning=docker
52+
ENV DOCKER_VERSION=19.03.8
53+
54+
RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz \
55+
&& tar xzvf docker-${DOCKER_VERSION}.tgz --strip 1 \
56+
-C /usr/local/bin docker/docker \
57+
&& rm docker-${DOCKER_VERSION}.tgz
58+
59+
# Slim image
60+
#============
61+
FROM final-base as slim
62+
63+
ENV RENOVATE_BINARY_SOURCE=docker
64+
65+
# Full image
66+
#============
67+
FROM final-base as latest
68+
69+
RUN apt-get update && \
70+
apt-get install -y gpg wget unzip xz-utils openssh-client bsdtar build-essential openjdk-11-jre-headless dirmngr && \
71+
rm -rf /var/lib/apt/lists/*
72+
73+
74+
## Gradle (needs java-jre, installed above)
75+
76+
# renovate: datasource=gradle-version depName=gradle versioning=maven
77+
ENV GRADLE_VERSION=6.3
78+
79+
RUN wget --no-verbose https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip && \
80+
unzip -q -d /opt/ gradle-$GRADLE_VERSION-bin.zip && \
81+
rm -f gradle-$GRADLE_VERSION-bin.zip && \
82+
mv /opt/gradle-$GRADLE_VERSION /opt/gradle && \
83+
ln -s /opt/gradle/bin/gradle /usr/local/bin/gradle
84+
85+
# Erlang
86+
87+
RUN cd /tmp && \
88+
curl https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb -o erlang-solutions_1.0_all.deb && \
89+
dpkg -i erlang-solutions_1.0_all.deb && \
90+
rm -f erlang-solutions_1.0_all.deb
91+
92+
ENV ERLANG_VERSION=22.0.2-1
93+
94+
RUN apt-get update && \
95+
apt-cache policy esl-erlang && \
96+
apt-get install -y esl-erlang=1:$ERLANG_VERSION && \
97+
rm -rf /var/lib/apt/lists/*
98+
99+
# Elixir
100+
101+
ENV ELIXIR_VERSION=1.8.2
102+
103+
RUN curl -L https://github.com/elixir-lang/elixir/releases/download/v${ELIXIR_VERSION}/Precompiled.zip -o Precompiled.zip && \
104+
mkdir -p /opt/elixir-${ELIXIR_VERSION}/ && \
105+
unzip Precompiled.zip -d /opt/elixir-${ELIXIR_VERSION}/ && \
106+
rm Precompiled.zip
107+
108+
ENV PATH $PATH:/opt/elixir-${ELIXIR_VERSION}/bin
109+
110+
# PHP Composer
111+
112+
RUN echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu bionic main" > /etc/apt/sources.list.d/ondrej-php.list && \
113+
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 14AA40EC0831756756D7F66C4F4EA0AAE5267A6C && \
114+
apt-get update && \
115+
apt-get -y install php7.4-cli php7.4-mbstring php7.4-curl && \
116+
rm -rf /var/lib/apt/lists/*
117+
118+
# renovate: datasource=github-releases depName=composer/composer
119+
ENV COMPOSER_VERSION=1.10.1
120+
121+
RUN php -r "copy('https://github.com/composer/composer/releases/download/$COMPOSER_VERSION/composer.phar', '/usr/local/bin/composer');"
122+
123+
RUN chmod +x /usr/local/bin/composer
124+
125+
# Go Modules
126+
127+
RUN apt-get update && apt-get install -y bzr mercurial && \
128+
rm -rf /var/lib/apt/lists/*
129+
130+
ENV GOLANG_VERSION=1.13.4
131+
132+
# Disable GOPROXY and GOSUMDB until we offer a solid solution to configure
133+
# private repositories.
134+
ENV GOPROXY=direct GOSUMDB=off
135+
136+
RUN wget -q -O go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz" && \
137+
tar -C /usr/local -xzf go.tgz && \
138+
rm go.tgz && \
139+
export PATH="/usr/local/go/bin:$PATH"
140+
141+
ENV GOPATH /go
142+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
143+
144+
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
145+
146+
ENV CGO_ENABLED=0
147+
148+
# Python
149+
150+
RUN apt-get update && apt-get install -y python3.8-dev python3.8-venv python3-distutils && \
151+
rm -rf /var/lib/apt/lists/*
152+
153+
RUN rm -fr /usr/bin/python3 && ln /usr/bin/python3.8 /usr/bin/python3
154+
RUN rm -rf /usr/bin/python && ln /usr/bin/python3.8 /usr/bin/python
155+
156+
# Pip
157+
158+
RUN curl --silent https://bootstrap.pypa.io/get-pip.py | python
159+
160+
# CocoaPods
161+
RUN apt-get update && apt-get install -y ruby ruby2.5-dev && rm -rf /var/lib/apt/lists/*
162+
RUN ruby --version
163+
164+
# renovate: datasource=rubygems depName=cocoapods versioning=ruby
165+
ENV COCOAPODS_VERSION 1.9.0
166+
RUN gem install --no-rdoc --no-ri cocoapods -v ${COCOAPODS_VERSION}
167+
168+
USER ubuntu
169+
170+
# HOME does not get passed after user switch :-(
171+
ENV HOME=/home/ubuntu
172+
173+
# Cargo
174+
175+
ENV RUST_BACKTRACE=1 \
176+
PATH=${HOME}/.cargo/bin:$PATH
177+
178+
ENV RUST_VERSION=1.36.0
179+
180+
RUN set -ex ;\
181+
curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path --profile minimal --default-toolchain ${RUST_VERSION} -y
182+
183+
# Mix and Rebar
184+
185+
RUN mix local.hex --force
186+
RUN mix local.rebar --force
187+
188+
# Pipenv
189+
190+
ENV PATH="${HOME}/.local/bin:$PATH"
191+
192+
RUN pip install --user pipenv
193+
194+
# Poetry
195+
196+
# renovate: datasource=github-releases depName=python-poetry/poetry
197+
ENV POETRY_VERSION=1.0.5
198+
199+
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - --version ${POETRY_VERSION}
200+
201+
ENV PATH="${HOME}/.poetry/bin:$PATH"
202+
RUN poetry config virtualenvs.in-project false
203+
204+
# Renovate
205+
#=========
206+
FROM $IMAGE as final
207+
208+
209+
COPY package.json .
210+
211+
COPY --from=tsbuild /usr/src/app/dist dist
212+
COPY --from=tsbuild /usr/src/app/node_modules node_modules
213+
COPY bin bin
214+
COPY data data
215+
216+
217+
# Numeric user ID for the ubuntu user. Used to indicate a non-root user to OpenShift
218+
USER 1000
219+
220+
ENTRYPOINT ["node", "/usr/src/app/dist/renovate.js"]
221+
CMD []

dockerfiles/Dockerfile.renovate.v2

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# https://github.com/renovatebot/docker-renovate
2+
# renovate: datasource=npm depName=renovate versioning=npm
3+
ARG RENOVATE_VERSION=23.25.1
4+
5+
# Base image
6+
#============
7+
FROM renovate/buildpack:2@sha256:f8a63698b56735e4db67d52aa5948c807117222ca01927be5564ef70b7a5fee5 AS base
8+
9+
LABEL name="renovate"
10+
LABEL org.opencontainers.image.source="https://github.com/renovatebot/renovate" \
11+
org.opencontainers.image.url="https://renovatebot.com" \
12+
org.opencontainers.image.licenses="AGPL-3.0-only"
13+
14+
# renovate: datasource=docker versioning=docker
15+
RUN install-tool node 12.18.3
16+
17+
# renovate: datasource=npm versioning=npm
18+
RUN install-tool yarn 1.22.5
19+
20+
# Build image
21+
#============
22+
FROM base as tsbuild
23+
24+
# use buildin python to faster build
25+
RUN install-apt build-essential python3
26+
RUN npm install -g yarn-deduplicate
27+
28+
COPY package.json .
29+
COPY yarn.lock .
30+
31+
RUN yarn install --frozen-lockfile --link-duplicates
32+
33+
COPY tsconfig.json .
34+
COPY tsconfig.app.json .
35+
COPY src src
36+
37+
RUN set -ex; \
38+
yarn build; \
39+
chmod +x dist/*.js;
40+
41+
ARG RENOVATE_VERSION
42+
RUN yarn add renovate@${RENOVATE_VERSION} --link-duplicates
43+
RUN yarn-deduplicate --strategy highest
44+
RUN yarn install --frozen-lockfile --link-duplicates --production
45+
46+
# check is re2 is usable
47+
RUN node -e "new require('re2')('.*').exec('test')"
48+
49+
50+
# TODO: enable
51+
#COPY src src
52+
#RUN yarn build
53+
# compatability file
54+
#RUN echo "require('./index.js');" > dist/renovate.js
55+
#RUN cp -r ./node_modules/renovate/data ./dist/data
56+
57+
58+
# Final image
59+
#============
60+
FROM base as final
61+
62+
# renovate: datasource=docker versioning=docker
63+
RUN install-tool docker 19.03.12
64+
65+
ENV RENOVATE_BINARY_SOURCE=docker
66+
67+
COPY --from=tsbuild /usr/src/app/package.json package.json
68+
COPY --from=tsbuild /usr/src/app/dist dist
69+
70+
# TODO: remove
71+
COPY --from=tsbuild /usr/src/app/node_modules node_modules
72+
73+
# exec helper
74+
COPY bin/ /usr/local/bin/
75+
RUN ln -sf /usr/src/app/dist/renovate.js /usr/local/bin/renovate;
76+
RUN ln -sf /usr/src/app/dist/config-validator.js /usr/local/bin/renovate-config-validator;
77+
CMD ["renovate"]
78+
79+
ARG RENOVATE_VERSION
80+
81+
RUN npm --no-git-tag-version version ${RENOVATE_VERSION} && renovate --version;
82+
83+
LABEL org.opencontainers.image.version="${RENOVATE_VERSION}"
84+
85+
# Numeric user ID for the ubuntu user. Used to indicate a non-root user to OpenShift
86+
USER 1000

dockerfiles/Dockerfile.test.v1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM golang:1.15 as builder
2+
COPY . /code
3+
WORKDIR /code
4+
RUN unset GOPATH && go test -v ./... && \
5+
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o out/check ./cmd/check && \
6+
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o out/in ./cmd/in && \
7+
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o out/out ./cmd/out
8+
FROM alpine:3.12
9+
RUN mkdir -p /opt/resource
10+
COPY --from=builder /code/out/* /opt/resource/
11+
ENV VERSION_FILE /opt/resource/version
12+
RUN echo "$(date +%Y/%M/%d-%T)" > $VERSION_FILE

0 commit comments

Comments
 (0)