Skip to content

Commit edf24d8

Browse files
jminiwing328
authored andcommitted
Improve Docker Tags (#390)
1 parent 33fcd28 commit edf24d8

4 files changed

Lines changed: 74 additions & 5 deletions

File tree

.travis.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,27 @@ after_success:
124124
popd;
125125
fi;
126126
fi;
127-
## docker: build and push openapi-generator-online to DockerHub
128-
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/openapi-generator-online && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME && echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME"; fi; fi
129-
## docker: build cli image and push to Docker Hub
130-
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi
131-
127+
## docker build and push images to DockerHub (openapi-generator-online, openapi-generator-cli)
128+
- if [ $DOCKER_HUB_USERNAME ]; then
129+
read -r MVN_VERSION_FOR_DOCKER_TAG < target/ci/version-for-docker-tag.txt
130+
echo "Tag for Docker derived from maven version: $MVN_VERSION_FOR_DOCKER_TAG"
131+
echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin
132+
if [ ! -z "$TRAVIS_TAG" ]; then
133+
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online
134+
docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli
135+
elif [ "$TRAVIS_BRANCH" == "master" ]; then
136+
docker build -t $DOCKER_GENERATOR_IMAGE_NAME -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online
137+
docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli
138+
else
139+
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-online
140+
docker build -t $DOCKER_GENERATOR_IMAGE_NAME:$MVN_VERSION_FOR_DOCKER_TAG ./modules/openapi-generator-cli
141+
fi;
142+
if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" == "master" ] || [ "$TRAVIS_BRANCH" == "3.1.x" ] || [ "$TRAVIS_BRANCH" == "4.0.x" ];
143+
docker push $DOCKER_GENERATOR_IMAGE_NAME
144+
echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME";
145+
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME
146+
echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME";
147+
fi;
148+
fi;
132149
env:
133150
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.x

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ To reinstall with the latest master, run `brew reinstall --HEAD openapi-generato
193193
- [https://hub.docker.com/r/openapitools/openapi-generator-cli/](https://hub.docker.com/r/openapitools/openapi-generator-cli/) (official CLI)
194194
- [https://hub.docker.com/r/openapitools/openapi-generator-online/](https://hub.docker.com/r/openapitools/openapi-generator-online/) (official web service)
195195

196+
#### Docker tags
197+
198+
`lastest` Tag contains the continuously built version from our `master` branch.
199+
200+
`v0.0.0` Tags correspond to a released version in this git repository. Examples:
201+
202+
* `v3.0.0` Tag
203+
* `v3.0.1` Tag
204+
* `v3.0.2` Tag
205+
206+
`0.0.x` Tags correspond to continuously built versions (after each commit), regardless of the branch it is built from. Examples:
207+
208+
* `3.0.x` Tag: contains first `3.0.2-SNAPSHOT` and after the `3.0.2` release it contains `3.0.3-SNAPSHOT` and so on.
209+
* `3.1.x` Tag: contains first `3.1.0-SNAPSHOT` and after the `3.1.0` release it contains `3.1.1-SNAPSHOT` and so on.
210+
* `4.0.x` Tag: contains first `4.0.0-SNAPSHOT` and after the `4.0.0` release it contains `4.0.1-SNAPSHOT` and so on.
211+
196212

197213
#### OpenAPI Generator CLI Docker Image
198214

pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,41 @@
101101
<directory>target</directory>
102102
<finalName>${project.artifactId}-${project.version}</finalName>
103103
<plugins>
104+
<plugin>
105+
<groupId>org.codehaus.mojo</groupId>
106+
<artifactId>build-helper-maven-plugin</artifactId>
107+
<version>3.0.0</version>
108+
<executions>
109+
<execution>
110+
<id>parse-version</id>
111+
<goals>
112+
<goal>parse-version</goal>
113+
</goals>
114+
</execution>
115+
</executions>
116+
</plugin>
117+
<plugin>
118+
<artifactId>maven-resources-plugin</artifactId>
119+
<version>3.0.2</version>
120+
<executions>
121+
<execution>
122+
<id>copy-resources</id>
123+
<phase>package</phase>
124+
<goals>
125+
<goal>copy-resources</goal>
126+
</goals>
127+
<configuration>
128+
<outputDirectory>${project.build.directory}/</outputDirectory>
129+
<resources>
130+
<resource>
131+
<directory>${project.basedir}/CI/resources</directory>
132+
<filtering>true</filtering>
133+
</resource>
134+
</resources>
135+
</configuration>
136+
</execution>
137+
</executions>
138+
</plugin>
104139
<plugin>
105140
<groupId>net.revelc.code</groupId>
106141
<artifactId>formatter-maven-plugin</artifactId>

0 commit comments

Comments
 (0)