Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOOL IMPROVEMENT] Dockerfile with subfolder url #423

Open
DeAlexPesh opened this issue May 30, 2023 · 1 comment
Open

[TOOL IMPROVEMENT] Dockerfile with subfolder url #423

DeAlexPesh opened this issue May 30, 2023 · 1 comment
Assignees

Comments

@DeAlexPesh
Copy link

DeAlexPesh commented May 30, 2023

FROM node:lts-alpine AS build
ARG TOOLZ_REPO="https://github.com/CorentinTh/it-tools.git"
RUN apk add --no-cache git \
 && rm -rf /var/cache/apk/*
WORKDIR /app
RUN git clone ${TOOLZ_REPO} toolz
WORKDIR /app/toolz
# make sub url
ARG SUB_URL=
RUN if [[ -n "$SUB_URL" ]] \
 ; then \
 sed -i -e "s|href=\"/|href=\"|" index.html \
 && sed -i -e "s|src: \'/|src: \'|" vite.config.ts \
 && sed -i -e "s|routes:|base: config.app.baseUrl, routes:|" src/router.ts \
 && sed -i -e "s|resolve:|base: process.env.SUB_URL + '/', resolve:|" vite.config.ts \
 && sed -i -e "s|default: '/',|default: process.env.SUB_URL,|" src/config.ts \
 && sed -i -e "s|start_url: '/?utm_source=pwa&utm_medium=pwa',|start_url: process.env.SUB_URL + '/?utm_source=pwa\&utm_medium=pwa',|" vite.config.ts \
 ; fi
# compile
RUN npm install -g pnpm \
 && pnpm i --frozen-lockfile \
 && pnpm build

FROM nginx:stable-alpine AS production
COPY --from=build /app/toolz/dist /usr/share/nginx/html
COPY --from=build /app/toolz/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

change arg SUB_URL to need subfolder
ex: ARG SUB_URL=/sub for http://domain.org/sub/
build image:

docker build -t it-tools:mode /folder_with_dockerfile/. -f /folder_with_dockerfile/Dockerfile

@DeAlexPesh DeAlexPesh changed the title [OTHER] May 31, 2023
@DeAlexPesh DeAlexPesh changed the title [OTHER] Dockerfile with subfolder url May 31, 2023
@cvc90
Copy link

cvc90 commented Jun 4, 2023

@CorentinTh Do you plan to add this excellent option in the it-tools code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants