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:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
variables:
CANTALOUPE_VERSION: 5.0.4
CANTALOUPE_PORT: 8182
script:
- ./generate-dockerfile $BUILD_WITH
- ./generate-dockerfile --version=$CANTALOUPE_VERSION --port=$CANTALOUPE_PORT $BUILD_WITH
- mkdir -p /kaniko/.docker
- 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
......
ARG VERSION=5.0.4
FROM debian:buster-slim AS build
FROM index.docker.io/library/debian:buster-slim AS build
WORKDIR /
RUN apt-get -qq update && \
apt-get -qq install wget unzip && \
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 && \
mv cantaloupe-${VERSION} cantaloupe && \
mv cantaloupe-{{ version }} cantaloupe && \
{%- if kakadu %}
mkdir /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
rm cantaloupe/cantaloupe.properties.sample
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
ENV VERSION=${VERSION}
ENTRYPOINT ["/home/cantaloupe/run.sh", "$VERSION"]
ENTRYPOINT ["/home/cantaloupe/run.sh", "{{ version }}"]
CMD ["-Dcantaloupe.config=/home/cantaloupe/app/cantaloupe.properties"]
ARG HTTP_PORT=8182
HEALTHCHECK --start-period=30s CMD curl -sf 0.0.0.0:${HTTP_PORT} -o /dev/null || exit 1
HEALTHCHECK --start-period=30s CMD curl -sf 0.0.0.0:{{ port }} -o /dev/null || exit 1
RUN useradd cantaloupe && mkdir -p /home/cantaloupe/.cache/cantaloupe && chown -R cantaloupe: /home/cantaloupe/.cache
COPY --chown=cantaloupe --from=build /cantaloupe/ /home/cantaloupe/app/
ADD --chown=cantaloupe ./run.sh /home/cantaloupe/run.sh
......
No preview for this file type
......@@ -12,6 +12,8 @@ struct TmpltArgs {
kakadu: bool,
openjpeg: bool,
turbojpeg: bool,
version: String,
port: String,
}
fn main() -> Result<()> {
......@@ -33,6 +35,8 @@ fn main() -> Result<()> {
kakadu: false,
openjpeg: false,
turbojpeg: false,
version: String::with_capacity(5),
port: String::with_capacity(5),
};
for arg in env::args().skip(1) {
......@@ -46,8 +50,22 @@ fn main() -> Result<()> {
tmplt_args.openjpeg = true;
} else if arg == "--turbojpeg" {
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(
"Dockerfile.template",
&Context::from_serialize(&tmplt_args)?,
......
Markdown is supported
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