FROM node:22-alpine AS build
RUN apk add --no-cache npm git curl build-base net-tools python3 postgresql-dev

WORKDIR /lamassu-server

COPY ["packages/server/package.json", "package-lock.json", "./"]
RUN npm version --allow-same-version --git-tag-version false --commit-hooks false 1.0.0
RUN npm install --production

COPY packages/server/ ./


FROM node:22-alpine AS l-s-base
RUN apk add --no-cache npm git curl bash libpq openssl ca-certificates

COPY --from=build /lamassu-server /lamassu-server


FROM l-s-base AS l-s

RUN chmod +x /lamassu-server/bin/lamassu-server-entrypoint.sh

EXPOSE 3000

ENTRYPOINT [ "/lamassu-server/bin/lamassu-server-entrypoint.sh" ]


FROM node:22-alpine AS build-ui
RUN apk add --no-cache npm git curl build-base python3

WORKDIR /app

COPY ["packages/admin-ui/package.json", "package-lock.json", "./"]

RUN npm version --allow-same-version --git-tag-version false --commit-hooks false 1.0.0
RUN npm install

COPY packages/admin-ui/ ./
RUN npm run build


FROM l-s-base AS l-a-s
COPY --from=build-ui /app/build /lamassu-server/public

RUN chmod +x /lamassu-server/bin/lamassu-admin-server-entrypoint.sh

EXPOSE 443

ENTRYPOINT [ "/lamassu-server/bin/lamassu-admin-server-entrypoint.sh" ]