Add multi-stage Dockerfile, docker-compose, and fix insert conflict
Rebuild Dockerfile with 3 stages (CSS, uberjar, runtime) on port 3030. Add docker-compose.yml loading .env. Fix insert-price! ON CONFLICT to target (time_dk, price_area) matching the actual unique index. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+20
-13
@@ -1,15 +1,22 @@
|
|||||||
# syntax = docker/dockerfile:1.2
|
FROM node:22-alpine AS css
|
||||||
FROM clojure:openjdk-17 AS build
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY resources/css resources/css
|
||||||
|
COPY src src
|
||||||
|
RUN npx @tailwindcss/cli -i resources/css/input.css -o resources/public/css/output.css --minify
|
||||||
|
|
||||||
WORKDIR /
|
FROM clojure:temurin-21-tools-deps-alpine AS build
|
||||||
COPY . /
|
WORKDIR /app
|
||||||
|
COPY deps.edn build.clj ./
|
||||||
|
RUN clojure -P && clojure -P -T:build
|
||||||
|
COPY . .
|
||||||
|
COPY --from=css /app/resources/public/css/output.css resources/public/css/output.css
|
||||||
|
RUN clojure -T:build all
|
||||||
|
|
||||||
RUN clj -Sforce -T:build all
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
WORKDIR /app
|
||||||
FROM azul/zulu-openjdk-alpine:17
|
COPY --from=build /app/target/elprice-standalone.jar app.jar
|
||||||
|
EXPOSE 3030
|
||||||
COPY --from=build /target/elprice-standalone.jar /elprice/elprice-standalone.jar
|
ENV PORT=3030
|
||||||
|
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||||
EXPOSE $PORT
|
|
||||||
|
|
||||||
ENTRYPOINT exec java $JAVA_OPTS -jar /elprice/elprice-standalone.jar
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "3030:3030"
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
restart: unless-stopped
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
-- :doc Insert a day-ahead price record, skip if already exists
|
-- :doc Insert a day-ahead price record, skip if already exists
|
||||||
INSERT INTO day_ahead_prices (time_utc, time_dk, price_area, price_dkk, price_eur)
|
INSERT INTO day_ahead_prices (time_utc, time_dk, price_area, price_dkk, price_eur)
|
||||||
VALUES (:time-utc, :time-dk, :price-area, :price-dkk, :price-eur)
|
VALUES (:time-utc, :time-dk, :price-area, :price-dkk, :price-eur)
|
||||||
ON CONFLICT (time_utc, price_area) DO NOTHING;
|
ON CONFLICT (time_dk, price_area) DO NOTHING;
|
||||||
|
|
||||||
-- :name get-prices-for-date :? :*
|
-- :name get-prices-for-date :? :*
|
||||||
-- :doc Get all prices for a given date (time_dk local date) and price area
|
-- :doc Get all prices for a given date (time_dk local date) and price area
|
||||||
|
|||||||
Reference in New Issue
Block a user