Skip to content

Commit

Permalink
Build play-builder in docker (#72)
Browse files Browse the repository at this point in the history
* Build play-builder in docker

* fix

* container template
  • Loading branch information
gheine authored Nov 29, 2022
1 parent c16b786 commit c673b1c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 96 deletions.
15 changes: 9 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pipeline {
containerTemplates([
containerTemplate(name: 'node', image: 'docker:20', resourceRequestCpu: '1', resourceRequestMemory: '2Gi', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'play', image: 'docker:20', resourceRequestCpu: '1', resourceRequestMemory: '2Gi', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'play-builder', image: 'flowdocker/play_builder:latest-java13', resourceRequestCpu: '1', resourceRequestMemory: '2Gi', command: 'cat', ttyEnabled: true)
containerTemplate(name: 'play-builder', image: 'docker:20', resourceRequestCpu: '1', resourceRequestMemory: '2Gi', command: 'cat', ttyEnabled: true)
])
}
}
Expand Down Expand Up @@ -87,14 +87,17 @@ pipeline {
steps {
container('play-builder') {
script {
sh "apk add --no-cache docker-cli openssh curl git ruby"
semver = VERSION.printable()
SBT_VERSION = '1.8.0'
withCredentials([usernamePassword(credentialsId: 'jenkins-x-github', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]){
withAWS(roleAccount: '479720515435', role: 'jenkins-build') {
docker.withRegistry('https://index.docker.io/v1/', 'jenkins-dockerhub') {
sh """mkdir /root/.ssh && chmod 0700 /root/.ssh"""
sh """ssh-keyscan -H github.com >> ~/.ssh/known_hosts"""
sh """cd play && ./build-play-builder ${VERSION.printable()} 13"""
sh """cd play && ./build-play-builder ${VERSION.printable()} 17"""
db = docker.build("flowdocker/play_builder:$semver-java13", "--network=host --build-arg GIT_PASSWORD=$GIT_PASSWORD --build-arg GIT_USERNAME=$GIT_USERNAME --build-arg SBT_VERSION=$SBT_VERSION -f Dockerfile.play_builder-13 .")
db.push()
db.push("latest-java13")
db = docker.build("flowdocker/play_builder:$semver-java17", "--network=host --build-arg GIT_PASSWORD=$GIT_PASSWORD --build-arg GIT_USERNAME=$GIT_USERNAME --build-arg SBT_VERSION=$SBT_VERSION -f Dockerfile.play_builder-17 .")
db.push()
db.push("latest-java17")
}
}
}
Expand Down
33 changes: 30 additions & 3 deletions play/Dockerfile.play_builder-13
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
FROM openjdk:13-jdk-alpine as builder

ARG GIT_USERNAME
ARG GIT_PASSWORD
ARG SBT_VERSION
ENV GIT_USERNAME $GIT_USERNAME
ENV GIT_PASSWORD $GIT_PASSWORD
ENV SBT_VERSION $SBT_VERSION

ENV PROJECTS_TO_BUILD "experience catalog label shopify webhook demandware harmonization tax order-messenger bundle metric shopify-markets calculator"

WORKDIR /root

RUN apk add --no-cache docker-cli openssh curl git ruby bash && \
mkdir /root/.ssh && chmod 0700 /root/.ssh && \
ssh-keyscan -H github.com >> ~/.ssh/known_hosts && \
curl -sL "https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz" | gunzip | tar -x -C /usr/local && \
ln -s /usr/local/sbt/bin/sbt /usr/local/bin/sbt && \
chmod 0755 /usr/local/bin/sbt

#RUN for repo in $PROJECTS_TO_BUILD; do \
RUN for repo in experience; do \
echo $repo; git clone --depth 1 https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/flowcommerce/$repo.git; cd $repo; sbt update; cd -; \
done

FROM openjdk:13-jdk-alpine

LABEL maintainer="tech@flow.io"

ENV SBT_VERSION 1.8.0
ARG SBT_VERSION
ENV SBT_VERSION $SBT_VERSION


WORKDIR /root

Expand All @@ -17,5 +44,5 @@ RUN apk update && apk upgrade && \
mkdir -p .sbt/ && \
mkdir -p .ivy2/

COPY .sbt/ .sbt/.
COPY .coursier/ .cache/coursier/v1/.
COPY --from=builder .sbt/ .sbt/.
COPY --from=builder .cache/ .cache/.
32 changes: 29 additions & 3 deletions play/Dockerfile.play_builder-17
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
FROM eclipse-temurin:17-jdk-alpine as builder

ARG GIT_USERNAME
ARG GIT_PASSWORD
ARG SBT_VERSION
ENV GIT_USERNAME $GIT_USERNAME
ENV GIT_PASSWORD $GIT_PASSWORD
ENV SBT_VERSION $SBT_VERSION

ENV PROJECTS_TO_BUILD "experience catalog label shopify webhook demandware harmonization tax order-messenger bundle metric shopify-markets calculator"

WORKDIR /root

RUN apk add --no-cache docker-cli openssh curl git ruby bash && \
mkdir /root/.ssh && chmod 0700 /root/.ssh && \
ssh-keyscan -H github.com >> ~/.ssh/known_hosts && \
curl -sL "https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz" | gunzip | tar -x -C /usr/local && \
ln -s /usr/local/sbt/bin/sbt /usr/local/bin/sbt && \
chmod 0755 /usr/local/bin/sbt

RUN for repo in $PROJECTS_TO_BUILD; do \
echo $repo; git clone --depth 1 https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/flowcommerce/$repo.git; cd $repo; sbt update; cd -; \
done

FROM eclipse-temurin:17-jdk-alpine

LABEL maintainer="tech@flow.io"

ENV SBT_VERSION 1.8.0
ARG SBT_VERSION
ENV SBT_VERSION $SBT_VERSION


WORKDIR /root

Expand All @@ -17,5 +43,5 @@ RUN apk update && apk upgrade && \
mkdir -p .sbt/ && \
mkdir -p .ivy2/

COPY .sbt/ .sbt/.
COPY .coursier/ .cache/coursier/v1/.
COPY --from=builder .sbt/ .sbt/.
COPY --from=builder .cache/ .cache/.
84 changes: 0 additions & 84 deletions play/build-play-builder

This file was deleted.

0 comments on commit c673b1c

Please sign in to comment.