@@ -185,44 +185,44 @@ object Package extends ScalaCommand[PackageOptions] {
185
185
186
186
lazy val debianSettings = DebianSettings (
187
187
shared = sharedSettings,
188
- maintainer = packageOptions.maintainer.mandatory(" maintainer" , " debian" ),
189
- description = packageOptions.description.mandatory(" description" , " debian" ),
188
+ maintainer = packageOptions.maintainer.mandatory(" -- maintainer" , " debian" ),
189
+ description = packageOptions.description.mandatory(" -- description" , " debian" ),
190
190
debianConflicts = packageOptions.debianOptions.conflicts,
191
191
debianDependencies = packageOptions.debianOptions.dependencies,
192
192
architecture = packageOptions.debianOptions.architecture.mandatory(
193
- " deb architecture" ,
193
+ " -- deb- architecture" ,
194
194
" debian"
195
195
)
196
196
)
197
197
198
198
lazy val macOSSettings = MacOSSettings (
199
199
shared = sharedSettings,
200
200
identifier =
201
- packageOptions.macOSidentifier.mandatory(" identifier parameter" , " macOs" )
201
+ packageOptions.macOSidentifier.mandatory(" -- identifier- parameter" , " macOs" )
202
202
)
203
203
204
204
lazy val redHatSettings = RedHatSettings (
205
205
shared = sharedSettings,
206
- description = packageOptions.description.mandatory(" description" , " redHat" ),
206
+ description = packageOptions.description.mandatory(" -- description" , " redHat" ),
207
207
license =
208
- packageOptions.redHatOptions.license.mandatory(" license" , " redHat" ),
208
+ packageOptions.redHatOptions.license.mandatory(" -- license" , " redHat" ),
209
209
release =
210
- packageOptions.redHatOptions.release.mandatory(" release" , " redHat" ),
210
+ packageOptions.redHatOptions.release.mandatory(" -- release" , " redHat" ),
211
211
rpmArchitecture = packageOptions.redHatOptions.architecture.mandatory(
212
- " rpm architecture" ,
212
+ " -- rpm- architecture" ,
213
213
" redHat"
214
214
)
215
215
)
216
216
217
217
lazy val windowsSettings = WindowsSettings (
218
218
shared = sharedSettings,
219
- maintainer = packageOptions.maintainer.mandatory(" maintainer" , " windows" ),
219
+ maintainer = packageOptions.maintainer.mandatory(" -- maintainer" , " windows" ),
220
220
licencePath = packageOptions.windowsOptions.licensePath.mandatory(
221
- " licence path" ,
221
+ " -- licence- path" ,
222
222
" windows"
223
223
),
224
224
productName = packageOptions.windowsOptions.productName.mandatory(
225
- " product name" ,
225
+ " -- product- name" ,
226
226
" windows"
227
227
),
228
228
exitDialog = packageOptions.windowsOptions.exitDialog,
@@ -249,29 +249,45 @@ object Package extends ScalaCommand[PackageOptions] {
249
249
imageResizerOpt = imageResizerOpt
250
250
).build()
251
251
}
252
- }
252
+ case PackageType .Docker =>
253
+ val exec = if (build.options.scalaJsOptions.enable) " node" else " sh"
254
+ val from = build.options.packageOptions.dockerOptions.from match {
255
+ case Some (baseImage) => baseImage
256
+ case None => if (build.options.scalaJsOptions.enable) " node" else " openjdk:8-jre-slim"
257
+ }
258
+ val repository = build.options.packageOptions.dockerOptions.imageRepository.mandatory(
259
+ " --docker-image-repository" ,
260
+ " docker"
261
+ )
262
+ val tag = build.options.packageOptions.dockerOptions.imageTag.getOrElse(" latest" )
263
+
264
+ val dockerSettings = DockerSettings (
265
+ from = from,
266
+ registry = build.options.packageOptions.dockerOptions.imageRegistry,
267
+ repository = repository,
268
+ tag = Some (tag),
269
+ exec = exec
270
+ )
253
271
254
- // build docker image
255
- if (build.options.packageOptions.isDockerEnabled) {
272
+ val appPath = os.temp.dir(prefix = " scala-cli-docker" ) / " app"
273
+ if (build.options.scalaJsOptions.enable) {
274
+ val linkerConfig = build.options.scalaJsOptions.linkerConfig
275
+ linkJs(build, appPath, Some (mainClass()), addTestInitializer = false , linkerConfig)
276
+ }
277
+ else {
278
+ bootstrap(build, appPath, mainClass(), () => alreadyExistsCheck())
279
+ }
256
280
257
- val exec = if (build.options.scalaJsOptions.enable) " node" else " sh"
258
- val from = build.options.packageOptions.dockerOptions.from match {
259
- case Some (baseImage) => baseImage
260
- case None => if (build.options.scalaJsOptions.enable) " node" else " adoptopenjdk/openjdk8"
261
- }
281
+ logger.message(
282
+ " Started building docker image with your application, it would take some time"
283
+ )
262
284
263
- val dockerSettings = DockerSettings (
264
- from = from,
265
- registry = build.options.packageOptions.dockerOptions.imageRegistry,
266
- repository = build.options.packageOptions.dockerOptions.imageRepository.mandatory(
267
- " image repository" ,
268
- " docker"
269
- ),
270
- tag = build.options.packageOptions.dockerOptions.imageTag,
271
- exec = exec
272
- )
285
+ DockerPackage (appPath, dockerSettings).build()
273
286
274
- DockerPackage (destPath, dockerSettings).build()
287
+ logger.message(
288
+ " Built docker image, run it with" + System .lineSeparator() +
289
+ s " docker run $repository: $tag"
290
+ )
275
291
}
276
292
277
293
logger.message {
@@ -281,6 +297,8 @@ object Package extends ScalaCommand[PackageOptions] {
281
297
else if (packageType == PackageType .Js )
282
298
s " Wrote $dest, run it with " + System .lineSeparator() +
283
299
" node " + printableDest
300
+ else if (packageType == PackageType .Docker )
301
+ " Wrote docker image"
284
302
else
285
303
s " Wrote $dest"
286
304
}
0 commit comments