Verified Commit 333368cb authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

insert port and version in template

parent 010b9344
Pipeline #33661 failed with stages
in 10 minutes and 46 seconds
...@@ -14,8 +14,11 @@ include: ...@@ -14,8 +14,11 @@ include:
image: image:
name: gcr.io/kaniko-project/executor:debug name: gcr.io/kaniko-project/executor:debug
entrypoint: [""] entrypoint: [""]
variables:
CANTALOUPE_VERSION: 5.0.4
CANTALOUPE_PORT: 8182
script: script:
- ./generate-dockerfile $BUILD_WITH - ./generate-dockerfile --version=$CANTALOUPE_VERSION --port=$CANTALOUPE_PORT $BUILD_WITH
- mkdir -p /kaniko/.docker - mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/$DOCKERFILE --destination $IMAGE_TAG - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/$DOCKERFILE --destination $IMAGE_TAG
......
ARG VERSION=5.0.4 FROM index.docker.io/library/debian:buster-slim AS build
FROM debian:buster-slim AS build
WORKDIR / WORKDIR /
RUN apt-get -qq update && \ RUN apt-get -qq update && \
apt-get -qq install wget unzip && \ apt-get -qq install wget unzip && \
apt-get clean apt-get clean
RUN wget -q https://github.com/cantaloupe-project/cantaloupe/releases/download/v${VERSION}/cantaloupe-${VERSION}.zip -O temp.zip && \ RUN wget -q https://github.com/cantaloupe-project/cantaloupe/releases/download/v{{ version }}/cantaloupe-{{ version }}.zip -O temp.zip && \
unzip temp.zip && \ unzip temp.zip && \
mv cantaloupe-${VERSION} cantaloupe && \ mv cantaloupe-{{ version }} cantaloupe && \
{%- if kakadu %} {%- if kakadu %}
mkdir /kakadu && \ mkdir /kakadu && \
mv cantaloupe/deps/Linux-x86-64/lib/* /kakadu && \ mv cantaloupe/deps/Linux-x86-64/lib/* /kakadu && \
...@@ -16,13 +14,11 @@ RUN wget -q https://github.com/cantaloupe-project/cantaloupe/releases/download/v ...@@ -16,13 +14,11 @@ RUN wget -q https://github.com/cantaloupe-project/cantaloupe/releases/download/v
rm cantaloupe/cantaloupe.properties.sample rm cantaloupe/cantaloupe.properties.sample
ADD ./cantaloupe.properties /cantaloupe/cantaloupe.properties ADD ./cantaloupe.properties /cantaloupe/cantaloupe.properties
FROM openjdk:16-slim-buster FROM index.docker.io/library/openjdk:16-slim-buster
# This variable assignment is mandatory to use the value in ENTRYPOINT # This variable assignment is mandatory to use the value in ENTRYPOINT
ENV VERSION=${VERSION} ENTRYPOINT ["/home/cantaloupe/run.sh", "{{ version }}"]
ENTRYPOINT ["/home/cantaloupe/run.sh", "$VERSION"]
CMD ["-Dcantaloupe.config=/home/cantaloupe/app/cantaloupe.properties"] CMD ["-Dcantaloupe.config=/home/cantaloupe/app/cantaloupe.properties"]
ARG HTTP_PORT=8182 HEALTHCHECK --start-period=30s CMD curl -sf 0.0.0.0:{{ port }} -o /dev/null || exit 1
HEALTHCHECK --start-period=30s CMD curl -sf 0.0.0.0:${HTTP_PORT} -o /dev/null || exit 1
RUN useradd cantaloupe && mkdir -p /home/cantaloupe/.cache/cantaloupe && chown -R cantaloupe: /home/cantaloupe/.cache RUN useradd cantaloupe && mkdir -p /home/cantaloupe/.cache/cantaloupe && chown -R cantaloupe: /home/cantaloupe/.cache
COPY --chown=cantaloupe --from=build /cantaloupe/ /home/cantaloupe/app/ COPY --chown=cantaloupe --from=build /cantaloupe/ /home/cantaloupe/app/
ADD --chown=cantaloupe ./run.sh /home/cantaloupe/run.sh ADD --chown=cantaloupe ./run.sh /home/cantaloupe/run.sh
......
No preview for this file type
...@@ -12,6 +12,8 @@ struct TmpltArgs { ...@@ -12,6 +12,8 @@ struct TmpltArgs {
kakadu: bool, kakadu: bool,
openjpeg: bool, openjpeg: bool,
turbojpeg: bool, turbojpeg: bool,
version: String,
port: String,
} }
fn main() -> Result<()> { fn main() -> Result<()> {
...@@ -33,6 +35,8 @@ fn main() -> Result<()> { ...@@ -33,6 +35,8 @@ fn main() -> Result<()> {
kakadu: false, kakadu: false,
openjpeg: false, openjpeg: false,
turbojpeg: false, turbojpeg: false,
version: String::with_capacity(5),
port: String::with_capacity(5),
}; };
for arg in env::args().skip(1) { for arg in env::args().skip(1) {
...@@ -46,8 +50,22 @@ fn main() -> Result<()> { ...@@ -46,8 +50,22 @@ fn main() -> Result<()> {
tmplt_args.openjpeg = true; tmplt_args.openjpeg = true;
} else if arg == "--turbojpeg" { } else if arg == "--turbojpeg" {
tmplt_args.turbojpeg = true; tmplt_args.turbojpeg = true;
} else if arg.starts_with("--version=") {
tmplt_args.version = String::from(arg.split("=").nth(1).unwrap());
} else if arg.starts_with("--port=") {
tmplt_args.port = String::from(arg.split("=").nth(1).unwrap());
} }
} }
if tmplt_args.version.is_empty() {
eprintln!("Please declare Cantaloupe version with `--version=x.y.z`");
process::exit(1);
}
if tmplt_args.port.is_empty() {
eprintln!("Please declare Cantaloupe port with `--port=xxxxx`");
process::exit(1);
}
let docker_image = TEMPLATE.render( let docker_image = TEMPLATE.render(
"Dockerfile.template", "Dockerfile.template",
&Context::from_serialize(&tmplt_args)?, &Context::from_serialize(&tmplt_args)?,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment