web: Update Dockerfile, Makefile

This commit is contained in:
2025-11-12 12:26:05 -06:00
parent c9e18d4fe4
commit 8fe330857d
6 changed files with 42 additions and 15 deletions

View File

@@ -5,12 +5,16 @@ WORKDIR /app
# Install project & dependencies # Install project & dependencies
COPY Project.toml /app/Backend/ COPY Project.toml /app/Backend/
COPY src /app/Backend/src COPY src /app/Backend/src
RUN julia --project=. -e 'using Pkg; Pkg.develop(path="Backend"); Pkg.add("HiGHS"); Pkg.precompile()' RUN julia --project=. -e 'using Pkg; Pkg.develop(path="Backend"); Pkg.add("HiGHS"); Pkg.add("JuMP"); Pkg.precompile()'
COPY docker/startup.jl ./ COPY docker/startup.jl ./
# Set timezone to US/Chicago
ENV TZ=US/Chicago
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Set default environment variables # Set default environment variables
ENV UCJL_HOST="0.0.0.0" ENV UCJL_HOST="0.0.0.0"
ENV UCJL_PORT="9000" ENV UCJL_PORT="9000"
# Run the server # Run the server
CMD ["julia", "--project=.", "startup.jl"] CMD ["julia", "--threads", "1", "--procs", "1", "--project=.", "startup.jl"]

View File

@@ -2,4 +2,14 @@ docker-build:
docker build . -t ucjl-backend docker build . -t ucjl-backend
docker-run: docker-run:
docker run --publish 9000:9000 --rm -it ucjl-backend docker stop ucjl-backend
docker rm ucjl-backend
docker run \
--restart always \
--detach \
--network custom \
--name ucjl-backend \
--volume ucjl_data:/app/Backend/jobs \
--memory 16g \
--cpus 4 \
ucjl-backend

View File

@@ -6,6 +6,7 @@
# Load required packages # Load required packages
using HiGHS using HiGHS
using JuMP
using Backend using Backend
const UCJL_HOST = get(ENV, "HOST", "0.0.0.0") const UCJL_HOST = get(ENV, "HOST", "0.0.0.0")
@@ -16,7 +17,8 @@ println("Host: $UCJL_HOST")
println("Port: $UCJL_PORT") println("Port: $UCJL_PORT")
println("Press Ctrl+C to stop the server") println("Press Ctrl+C to stop the server")
server = Backend.start_server(UCJL_HOST, UCJL_PORT; optimizer = HiGHS.Optimizer) Backend.setup_logger()
server = Backend.start_server(UCJL_HOST, UCJL_PORT; optimizer = optimizer_with_attributes(HiGHS.Optimizer, "mip_rel_gap" => 0.001))
try try
wait() wait()
catch e catch e

View File

@@ -99,7 +99,7 @@ function start_server(host, port; optimizer)
instance, instance,
optimizer = optimizer, optimizer = optimizer,
) )
UnitCommitment.optimize!(model) UnitCommitment.optimize!(model, UnitCommitment.XavQiuWanThi2019.Method(time_limit=900.0))
solution = UnitCommitment.solution(model) solution = UnitCommitment.solution(model)
UnitCommitment.write(solution_filename, solution) UnitCommitment.write(solution_filename, solution)
return return

View File

@@ -4,13 +4,15 @@ WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
COPY . . COPY . .
ARG REACT_APP_BACKEND_URL
ENV REACT_APP_BACKEND_URL=$REACT_APP_BACKEND_URL
RUN npm run build RUN npm run build
# Production Stage # Production Stage
FROM node:18-alpine AS production FROM node:18-alpine AS production
WORKDIR /app WORKDIR /app
COPY --from=build /app/build ./build COPY --from=build /app/build ./build
COPY server.js ./ COPY server.js ./
RUN npm install --production express RUN npm install --production express
EXPOSE 3000 EXPOSE 3000
CMD ["node", "server.js"] CMD ["node", "server.js"]

View File

@@ -1,5 +1,14 @@
docker-build: docker-build:
docker build . -t ucjl-frontend docker build . \
--build-arg REACT_APP_BACKEND_URL=https://ucjl.axavier.org/api \
-t ucjl-frontend
docker-run: docker-run:
docker run -e REACT_APP_BACKEND_URL=http://localhost:9000/api --publish 3000:3000 --rm -it ucjl-frontend docker stop ucjl-frontend
docker rm ucjl-frontend
docker run \
--detach \
--network custom \
--restart always \
--name ucjl-frontend \
ucjl-frontend