diff --git a/front/Containerfile b/front/Containerfile new file mode 100644 index 0000000000000000000000000000000000000000..3c501fb34d40a7dde2a9f89bfda2be576785900b --- /dev/null +++ b/front/Containerfile @@ -0,0 +1,43 @@ +FROM docker.io/nginxinc/nginx-unprivileged:1.27 + +ENV JULIA_PROJECT /app +ENV JULIA_DEPOT_PATH /app/julia +ENV JULIAUP_DEPOT_PATH /app/juliaup + +ARG JULIA_VERSION=1.10.5 + +# UID/GID should match with same arguments defined in: +# https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/mainline/debian/Dockerfile +ARG UID=101 +ARG GID=101 + +COPY --chown="$UID:$GID" . "$JULIA_PROJECT" + +RUN export HOME="$JULIA_PROJECT" \ + && curl -fsSL https://install.julialang.org \ + | sh -s -- --yes --default-channel "$JULIA_VERSION" + +ENV PATH "$PATH:$JULIA_PROJECT/.juliaup/bin" + +RUN cd "$JULIA_PROJECT" \ + && rm -rf public \ + && rm -rf storage \ + && cp front/Manifest.toml . \ + && julia -e 'using Pkg; Pkg.instantiate()' \ + && mkdir -p public \ + && chmod a+x front/entrypoint.sh + + +ARG PUBLIC_URL=localhost + +ARG NGINX_CONFIG=/etc/nginx/conf.d/default.conf + +COPY front/proxy.conf "$NGINX_CONFIG" + +RUN if [ -n "$PUBLIC_URL" ]; then \ + sed -i "s/localhost/$PUBLIC_URL/" "$NGINX_CONFIG"; \ + fi \ + && sed -i "s/80;/8080;/" "$NGINX_CONFIG" + +ENTRYPOINT ["/app/front/entrypoint.sh"] +CMD [] diff --git a/nginx/Containerfile.local b/front/Containerfile.local similarity index 69% rename from nginx/Containerfile.local rename to front/Containerfile.local index b3df602ff5622ee0cb56f310ea14f9e15f0ccbd9..ab09c3c7ce9dff6fdd15b032c7ea646aebfa41fb 100644 --- a/nginx/Containerfile.local +++ b/front/Containerfile.local @@ -1,6 +1,8 @@ FROM nginx:1.27.1 -COPY ./NyxUI.jl/nginx/proxy.conf /etc/nginx/conf.d/default.conf +# builds from NyxUI.jl's parent directory + +COPY ./NyxUI.jl/front/proxy.conf /etc/nginx/conf.d/default.conf ENV JULIAUP_DEPOT_PATH /juliaup ENV JULIA_DEPOT_PATH /julia @@ -9,6 +11,8 @@ ARG JULIA_VERSION=1.10.5 RUN curl -fsSL https://install.julialang.org \ | sh -s -- --yes --default-channel $JULIA_VERSION +ENV PATH "$PATH:/root/.juliaup/bin" + COPY ./NyxWidgets.jl /app/NyxWidgets.jl COPY ./NyxPlots.jl /app/NyxPlots.jl COPY ./NyxUI.jl /app/NyxUI.jl @@ -16,10 +20,9 @@ COPY ./NyxUI.jl /app/NyxUI.jl ENV JULIA_PROJECT /app/NyxUI.jl RUN cd /app/NyxUI.jl \ - && . /root/.profile \ && julia -e 'using Pkg; Pkg.add(path="../NyxWidgets.jl"); Pkg.add(path="../NyxPlots.jl"); Pkg.instantiate();' \ && mkdir -p public \ - && chmod a+x nginx/entrypoint.sh + && chmod a+x front/entrypoint.sh -ENTRYPOINT ["/app/NyxUI.jl/nginx/entrypoint.sh"] +ENTRYPOINT ["/app/NyxUI.jl/front/entrypoint.sh"] CMD [] diff --git a/nginx/Manifest.toml b/front/Manifest.toml similarity index 100% rename from nginx/Manifest.toml rename to front/Manifest.toml diff --git a/nginx/build-run-local.sh b/front/build-run-local.sh similarity index 92% rename from nginx/build-run-local.sh rename to front/build-run-local.sh index 78711e006c1db0b55e94ea8ad19d9ae1b20dc30b..2d209dc30aafc6fb78bdd3aa9c6a801dea58ad3f 100755 --- a/nginx/build-run-local.sh +++ b/front/build-run-local.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -CONTAINERFILE=nginx/Containerfile.local +CONTAINERFILE=front/Containerfile.local if ! [ -f "$CONTAINERFILE" -a -f routes.jl ]; then echo "Run $0 from the project root directory" diff --git a/nginx/build.sh b/front/build.sh similarity index 84% rename from nginx/build.sh rename to front/build.sh index f4938b5de31b077cccc3369ccd76917df4c6a16e..02619d93707323be1424da296f75d23b03c4f9ee 100755 --- a/nginx/build.sh +++ b/front/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -CONTAINERFILE=nginx/Containerfile +CONTAINERFILE=front/Containerfile if ! [ -f "$CONTAINERFILE" -a -f routes.jl ]; then echo "Run $0 from the project root directory" @@ -14,7 +14,7 @@ podman rmi -f $IMAGE || true podman build --tag $IMAGE -f "$CONTAINERFILE" . if [ "$1" = "--now" ]; then - podman run -d -p 8080:80 $IMAGE + podman run -d -p 8080:8080 $IMAGE CONTAINER=`podman ps | grep $IMAGE | cut -d' ' -f1` diff --git a/nginx/entrypoint.sh b/front/entrypoint.sh similarity index 86% rename from nginx/entrypoint.sh rename to front/entrypoint.sh index 187991f35cd284c25b1a67dcdf269e0bdb17c661..33fda00e28064a0d96dca7de3402029f69719ea6 100644 --- a/nginx/entrypoint.sh +++ b/front/entrypoint.sh @@ -2,8 +2,6 @@ echo "JULIA_PROJECT=$JULIA_PROJECT" -command -v julia || . /root/.bashrc - #export GENIE_ENV=prod #export GENIE_BASE_PATH=/g export BONITO_BASE_PATH=/bonito diff --git a/nginx/proxy.conf b/front/proxy.conf similarity index 100% rename from nginx/proxy.conf rename to front/proxy.conf diff --git a/nginx/Containerfile b/nginx/Containerfile deleted file mode 100644 index 0fcf90704c28ae90de73fdfda60a6decdf4f0c9c..0000000000000000000000000000000000000000 --- a/nginx/Containerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM nginx:1.27.1 - -ARG SERVER_NAME - -COPY nginx/proxy.conf /etc/nginx/conf.d/default.conf - -RUN if [ -n "$SERVER_NAME" ]; then \ - sed -i "s/server_name localhost/server_name $SERVER_NAME/" \ - /etc/nginx/conf.d/default.conf; \ - fi - -ENV JULIAUP_DEPOT_PATH /juliaup -ENV JULIA_DEPOT_PATH /julia -ARG JULIA_VERSION=1.10.5 - -RUN curl -fsSL https://install.julialang.org \ - | sh -s -- --yes --default-channel $JULIA_VERSION - -COPY . /app - -ENV JULIA_PROJECT /app - -RUN cd $JULIA_PROJECT \ - && . /root/.profile \ - && cp nginx/Manifest.toml . \ - && julia -e 'using Pkg; Pkg.instantiate()' \ - && mkdir -p public \ - && chmod a+x nginx/entrypoint.sh - -ENTRYPOINT ["/app/nginx/entrypoint.sh"] -CMD []