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