I got error: Not a valid command: dist (similar: set, iflast, last) when dockerizing a java playframework application

I am new to java playframework. I was asked to generate a hello world app in java playframework and dockerize it.

Requirements

java 17

playframework: 3.0.3

I installed java 17 on my system and downloaded sbt then entered this command to generate a boilerplate

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>sbt new playframework/play-java-seed.g8
</code>
<code>sbt new playframework/play-java-seed.g8 </code>
sbt new playframework/play-java-seed.g8 

Dockerfile

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Use an official OpenJDK runtime as a parent image for the build stage
FROM openjdk:11-jdk-slim AS builder
# Set the working directory in the container
WORKDIR /app
# Install necessary tools and sbt
RUN apt-get update && apt-get install -y curl unzip &&
curl -L -o /tmp/sbt.tgz https://github.com/sbt/sbt/releases/download/v1.4.7/sbt-1.4.7.tgz &&
mkdir -p /usr/local/bin/sbt &&
tar -xzf /tmp/sbt.tgz -C /usr/local/bin/sbt --strip-components=1 &&
ln -s /usr/local/bin/sbt/bin/sbt /usr/bin/sbt &&
rm /tmp/sbt.tgz
# Copy the application code to the container
COPY . /app
# Build the application
RUN sbt dist
# Use an official OpenJDK runtime as a parent image for the runtime stage
FROM openjdk:11-jre-slim
# Set the working directory in the container
WORKDIR /app
# Copy the distribution zip file from the builder stage
COPY --from=builder /app/target/universal/*.zip /app/
# Extract the distribution zip file
RUN apt-get update && apt-get install -y unzip &&
unzip /app/*.zip &&
rm /app/*.zip
# Expose the port that the Play app runs on
EXPOSE 9000
# Define the command to run the application
CMD ["sh", "/app/java-playframework/bin/java-playframework"]
</code>
<code># Use an official OpenJDK runtime as a parent image for the build stage FROM openjdk:11-jdk-slim AS builder # Set the working directory in the container WORKDIR /app # Install necessary tools and sbt RUN apt-get update && apt-get install -y curl unzip && curl -L -o /tmp/sbt.tgz https://github.com/sbt/sbt/releases/download/v1.4.7/sbt-1.4.7.tgz && mkdir -p /usr/local/bin/sbt && tar -xzf /tmp/sbt.tgz -C /usr/local/bin/sbt --strip-components=1 && ln -s /usr/local/bin/sbt/bin/sbt /usr/bin/sbt && rm /tmp/sbt.tgz # Copy the application code to the container COPY . /app # Build the application RUN sbt dist # Use an official OpenJDK runtime as a parent image for the runtime stage FROM openjdk:11-jre-slim # Set the working directory in the container WORKDIR /app # Copy the distribution zip file from the builder stage COPY --from=builder /app/target/universal/*.zip /app/ # Extract the distribution zip file RUN apt-get update && apt-get install -y unzip && unzip /app/*.zip && rm /app/*.zip # Expose the port that the Play app runs on EXPOSE 9000 # Define the command to run the application CMD ["sh", "/app/java-playframework/bin/java-playframework"] </code>
# Use an official OpenJDK runtime as a parent image for the build stage
FROM openjdk:11-jdk-slim AS builder

# Set the working directory in the container
WORKDIR /app

# Install necessary tools and sbt
RUN apt-get update && apt-get install -y curl unzip && 
    curl -L -o /tmp/sbt.tgz https://github.com/sbt/sbt/releases/download/v1.4.7/sbt-1.4.7.tgz && 
    mkdir -p /usr/local/bin/sbt && 
    tar -xzf /tmp/sbt.tgz -C /usr/local/bin/sbt --strip-components=1 && 
    ln -s /usr/local/bin/sbt/bin/sbt /usr/bin/sbt && 
    rm /tmp/sbt.tgz

# Copy the application code to the container
COPY . /app

# Build the application
RUN sbt dist

# Use an official OpenJDK runtime as a parent image for the runtime stage
FROM openjdk:11-jre-slim

# Set the working directory in the container
WORKDIR /app

# Copy the distribution zip file from the builder stage
COPY --from=builder /app/target/universal/*.zip /app/

# Extract the distribution zip file
RUN apt-get update && apt-get install -y unzip && 
    unzip /app/*.zip && 
    rm /app/*.zip

# Expose the port that the Play app runs on
EXPOSE 9000

# Define the command to run the application
CMD ["sh", "/app/java-playframework/bin/java-playframework"]

build.sbt

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>name := """hello-world"""
organization := "com.example"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.13.14"
libraryDependencies += guice
</code>
<code>name := """hello-world""" organization := "com.example" version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayJava) scalaVersion := "2.13.14" libraryDependencies += guice </code>
name := """hello-world"""
organization := "com.example"

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.13.14"

libraryDependencies += guice

Error

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>194.9 [info] welcome to sbt 1.10.0 (Oracle Corporation Java 17.0.2)
199.4 [info] loading settings for project app-build from plugins.sbt ...
201.1 [info] loading project definition from /app/project
239.5 [info] set current project to app (in build file:/app/)
239.8 [error] Not a valid command: dist (similar: set, iflast, last)
239.8 [error] Not a valid project ID: dist
239.8 [error] Expected ':'
239.8 [error] Not a valid key: dist (similar: bgList, test, history)
239.8 [error] dist
</code>
<code>194.9 [info] welcome to sbt 1.10.0 (Oracle Corporation Java 17.0.2) 199.4 [info] loading settings for project app-build from plugins.sbt ... 201.1 [info] loading project definition from /app/project 239.5 [info] set current project to app (in build file:/app/) 239.8 [error] Not a valid command: dist (similar: set, iflast, last) 239.8 [error] Not a valid project ID: dist 239.8 [error] Expected ':' 239.8 [error] Not a valid key: dist (similar: bgList, test, history) 239.8 [error] dist </code>
194.9 [info] welcome to sbt 1.10.0 (Oracle Corporation Java 17.0.2)
199.4 [info] loading settings for project app-build from plugins.sbt ...
201.1 [info] loading project definition from /app/project
239.5 [info] set current project to app (in build file:/app/)
239.8 [error] Not a valid command: dist (similar: set, iflast, last)
239.8 [error] Not a valid project ID: dist
239.8 [error] Expected ':'
239.8 [error] Not a valid key: dist (similar: bgList, test, history)
239.8 [error] dist

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật