diff --git a/Dockerfile b/Dockerfile index debc8e7..8d67611 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,42 @@ # The MIT License (MIT) Copyright (c) 2022 artipie.com # https://github.com/artipie/front/LICENSE.txt -FROM openjdk:21-oracle -ARG JAR_FILE +FROM openjdk:21-slim-bookworm as build + ENV JVM_OPTS="" LABEL description="Artipie front service" LABEL maintainer="g4s8.public@gmail.com" -RUN groupadd -r -g 2020 artipie && \ - adduser -M -r -g artipie -u 2021 -s /sbin/nologin artipie && \ - mkdir -p /etc/artipie /usr/lib/web-service /var/artipie && \ +# may optimize but require DOCKER_BUILDKIT=1 +# RUN --mount=target=/var/lib/apt/lists,type=cache \ +# --mount=target=/var/cache/apt,type=cache \ +# --mount=target=/root/.m2,type=cache + +RUN apt-get update + +RUN apt-get install -y --no-install-recommends \ + maven + +# RUN useradd -ms /sbin/nologin artipie -g artipie -u 2021 +COPY . /usr/local/src +WORKDIR /usr/local/src + +RUN mvn clean install -Pqulice +RUN mvn dependency:copy-dependencies -DoutputDirectory=target/dependencies/ + +FROM openjdk:21-oracle as run + +RUN groupadd -r -g 2020 artipie +RUN adduser -M -r -g artipie -u 2021 -s /sbin/nologin artipie +RUN mkdir -p /etc/artipie /usr/lib/web-service /var/artipie && \ chown artipie:artipie -R /etc/artipie /usr/lib/web-service /var/artipie -USER 2021:2020 -COPY target/dependency /usr/lib/web-service/lib -COPY target/${JAR_FILE} /usr/lib/web-service/app.jar +USER artipie:artipie +ARG JAR_FILE=front-*-SNAPSHOT.jar + +COPY --from=build /usr/local/src/target/dependencies/* /usr/lib/web-service/lib/ +COPY --from=build /usr/local/src/target/${JAR_FILE} /usr/lib/web-service/app.jar WORKDIR /var/web-service HEALTHCHECK --interval=10s --timeout=3s \ diff --git a/README.md b/README.md index 8c36be4..3d79668 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,40 @@ If you have any question or suggestions, do not hesitate to [create an issue](ht [Telegram](https://t.me/artipie). Artipie [roadmap](https://github.com/orgs/artipie/projects/3). +## Quick start + +```` +$ TAG=artipie-front +$ docker build . -t $TAG +$ docker run -p8080:8080 -eARTIPIE_REST=http://registry.local:8086 $TAG +```` + +## Build notes + +### Building with maven + +```` +mvn clean install -Pqulice +```` +(the qulice profile do not exists any more ?) + +To avoid build errors use Maven 3.2+. (the 3.8 looks like working too) + +### Export pom dependencies inside a folder + +```` +mvn dependency:copy-dependencies -DoutputDirectory=target/dependencies/ +```` + +## Dockerfile notes + +the Dockerfile use two layers, one build layer and the run layer (built with copying libraries from the build layer) + +## Environment variables (not exhaustive list) + +- ARTIPIE_REST : (default : http://localhost:8086) url to the artipie API (example : http://registry.local:8086), +- ARTIPIE_PORT : (default : 8080) port on which the server will listen to + ## How to contribute Please read [contributing rules](https://github.com/artipie/artipie/blob/master/CONTRIBUTING.md). @@ -26,10 +60,4 @@ Please read [contributing rules](https://github.com/artipie/artipie/blob/master/ Fork repository, make changes, send us a pull request. We will review your changes and apply them to the `master` branch shortly, provided they don't violate our quality standards. To avoid frustration, before -sending us your pull request please run full Maven build: - -``` -$ mvn clean install -Pqulice -``` - -To avoid build errors use Maven 3.2+. \ No newline at end of file +sending us your pull request please run full Maven build: \ No newline at end of file