I am trying to clone all my git repos in Jenkinsfile:
stage('Clone git') {
steps {sh 'mkdir repo1'
sh 'cd repo1'
dir ('repo1') {
git ([url : 'https://github.../repo1.git', branch : 'develop', credentialsId : '***'])}
sh 'mkdir repo2'
sh 'cd repo2'
dir ('repo2') {
git ([url : 'https://github.../repo2.git', branch : 'develop', credentialsId : '***'])}
}
}
stage('Build Docker') {
steps {sh 'cd ..'
sh 'docker build -t myimage .'
sh 'docker run myimage'
}
and then in my Dockerfile I have this:
FROM node:12.2.0-alpine
COPY . /myapp
WORKDIR /myapp
RUN apk update
FROM gradle:6.3-jdk11 AS build
COPY --chown=gradle:gradle . /repo1
WORKDIR /repo1
RUN gradle build --no-daemon
WORKDIR /repo2
RUN npm install
RUN ng serve
Please help me understand, if I am doing it the right way, specially the COPY command.
I think, it works this way: First it will clone git repos to repo1 and repo2 folders.
Then in Dockerfile it will create a layout inside myapp folder, it will copy both repo folders under the myapp folder.
The problem is, I need to run both services - in repo1 it is backend, gradle needs to be build, that's why I copy the gradle to repo1 folder, not sure if I should use myapp/repo1 here in COPY.
And repo2 is frontend, I think there is no need to COPY anything, just to select the WORKDIR repo2 and run the server.
So the question is, is it enough to COPY . /myapp in the first step, will it copy every repo folders there, or it just copies the docker image to myapp folder and I need to copy all the created folders separately?