Closed AuHau closed 1 month ago
I can take over this one an implement multi-steps builds based on the previous experience.
We have existing files already:
Did a check with a multi-stage build and Nginx as a base image. And we can check how it works.
At least one no so convenient thing we have with that approach is that it will all the time point Codex client node URL
to the http://127.0.0.1:8080
, as it is passed at build time, and you should update it each time you run it the app.
docker run --rm -p 3000:80 codexstorage/codex-marketplace-ui:latest
docker build \
--build-arg VITE_CODEX_API_URL=http://127.0.0.1:8080 \
--build-arg VITE_GEO_IP_URL=http://127.0.0.1 \
--no-cache \
-f Dockerfile \
-t codex-marketplace-ui .
Dockerfile
# Variables
ARG BUILDER=node:22-alpine
ARG IMAGE=nginx:1.27-alpine-slim
ARG APP_USER=root
ARG BUILD_HOME=/app
ARG BUILD_OUT=dist
ARG APP_HOME=/usr/share/nginx/html
ARG VITE_CODEX_API_URL=${VITE_CODEX_API_URL:-http://127.0.0.1:8080}
ARG VITE_GEO_IP_URL=${VITE_GEO_IP_URL:-http://127.0.0.1:8080}
# Build
FROM ${BUILDER} AS builder
ARG APP_USER
ARG BUILD_HOME
ARG VITE_CODEX_API_URL
ARG VITE_GEO_IP_URL
WORKDIR ${BUILD_HOME}
COPY --chown=${APP_USER}:${APP_USER} . .
RUN npm install
RUN npm run build
# Create
FROM ${IMAGE}
ARG APP_USER
ARG BUILD_HOME
ARG BUILD_OUT
ARG APP_HOME
WORKDIR ${APP_HOME}
COPY --chown=${APP_USER}:${APP_USER} --from=builder ${BUILD_HOME}/${BUILD_OUT} .
@veaceslavdoina I don't think VITE_GEO_IP_URL should be http://127.0.0.1:8080; it should point to a Docker instance of https://hub.docker.com/r/hakanensari/country, right ?
I don't think VITE_GEO_IP_URL should be http://127.0.0.1:8080/; it should point to a Docker instance of https://hub.docker.com/r/hakanensari/country, right ?
Yes and in Dockerfile we use ARG VITE_GEO_IP_URL=${VITE_GEO_IP_URL:-http://127.0.0.1:8080}
and during the build we override it using value from GitHub Actions secrets.
Just created a PR #55.
@veaceslavdoina I guess we can close this?
If all is working as expected let's close it.
Docker images are located in the codexstorage/codex-marketplace-ui
repository. Maybe it make sense to rename it like codexstorage/codex-app
, but that is another story.
So I have just deployed it and actually it does not work as expected 🙈
The problem is with Ngnix configuration - it correctly serves the file at root, but if you navigate to some subpage for example http://codex.cera.uhlici.cz/dashboard/availabilities
and reload the page you will get 404. The UI should be served on all paths.
I would like to self-host the UI because of HTTP/HTTPS API mismatches. Docker image for that would be great.