refactor: improved images for l-s and l-a-s

This commit is contained in:
Rafael Taranto 2024-08-09 11:03:43 +01:00
parent b9b532a633
commit 95df06250e
33 changed files with 137 additions and 749 deletions

View file

@ -1,36 +0,0 @@
FROM ubuntu:20.04 as base
ARG VERSION
ENV SERVER_VERSION=$VERSION
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Lisbon
RUN apt-get update
RUN apt-get install -y -q curl \
sudo \
git \
python2-minimal \
build-essential \
libpq-dev \
net-tools \
tar
RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
RUN apt-get install nodejs -y -q
FROM base as l-s-build
WORKDIR /lamassu
RUN git clone https://github.com/lamassu/lamassu-server -b ${SERVER_VERSION}
RUN rm -rf /lamassu/lamassu-server/public/*
RUN cd lamassu-server && npm install --production
RUN cd lamassu-server/new-lamassu-admin && npm install && npm run build
RUN cp -r /lamassu/lamassu-server/new-lamassu-admin/build/* /lamassu/lamassu-server/public
RUN rm -rf /lamassu/lamassu-server/new-lamassu-admin/node_modules
RUN tar -zcvf lamassu-server-$SERVER_VERSION.tar.gz lamassu-server/
ENTRYPOINT [ "/bin/bash" ]

View file

@ -1,40 +0,0 @@
FROM ubuntu:20.04 as base
ARG VERSION
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Lisbon
RUN apt-get update
RUN apt-get install -y -q curl \
sudo \
git \
python2-minimal \
build-essential \
libpq-dev \
net-tools \
tar
RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
RUN apt-get install nodejs -y -q
FROM base as l-s-build
WORKDIR lamassu-server
# # Prevent cache invalidation when we only change version numbers
COPY ["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 . ./
RUN mkdir -p public
RUN rm -rf public/*
RUN cd new-lamassu-admin && npm install && npm run build
RUN cp -r new-lamassu-admin/build/* -t public/
RUN rm -rf new-lamassu-admin/node_modules
RUN cd .. && tar -zcvf lamassu-server.tar.gz ./lamassu-server
ENTRYPOINT [ "/bin/bash" ]

View file

@ -0,0 +1,40 @@
FROM alpine:3.14 as build-ui
RUN apk add --no-cache nodejs npm git curl build-base python3
COPY ["new-lamassu-admin/package.json", "new-lamassu-admin/package-lock.json", "./"]
RUN npm version --allow-same-version --git-tag-version false --commit-hooks false 1.0.0
RUN npm install
COPY new-lamassu-admin/ ./
RUN npm run build
FROM alpine:3.14 as build
RUN apk add --no-cache nodejs npm git curl build-base net-tools python3 postgresql-dev
WORKDIR lamassu-server
COPY ["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 . ./
FROM alpine:3.14
RUN apk add --no-cache nodejs npm git curl bash libpq openssl
COPY --from=build /lamassu-server /lamassu-server
COPY --from=build-ui /build /lamassu-server/public
WORKDIR /lamassu-server/
RUN chmod +x bin/lamassu-server-entrypoint.sh
EXPOSE 3000
ENTRYPOINT [ "/lamassu-server/bin/lamassu-server-entrypoint.sh" ]
EXPOSE 443
ENTRYPOINT [ "node" ]
CMD [ "/lamassu-server/bin/lamassu-admin-server" ]

View file

@ -1,13 +0,0 @@
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
echo "Error: no arguments specified"
echo "Usage: ./build.sh <SERVER_VERSION_TAG>"
exit 1
fi
docker build --rm --build-arg VERSION=$1 --tag l-s-prepackage:$1 --file Dockerfile .
id=$(docker create l-s-prepackage:$1)
docker cp $id:/lamassu/lamassu-server-$1.tar.gz ./lamassu-server-$1.tar.gz
docker rm -v $id

View file

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -e
docker build -t build:latest -f build/Dockerfile.ci .
id=$(docker create build)
docker cp $id:/lamassu-server.tar.gz ./lamassu-server.tar.gz
docker rm -v $id

16
build/ci.Dockerfile Normal file
View file

@ -0,0 +1,16 @@
FROM alpine:3.14
RUN apk add --no-cache nodejs npm git curl build-base net-tools python3 postgresql-dev
WORKDIR lamassu-server
COPY ["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 . ./
RUN cd new-lamassu-admin && npm install && npm run build
RUN mv new-lamassu-admin/build public/
RUN rm -rf new-lamassu-admin/node_modules
RUN cd .. && tar -zcvf lamassu-server.tar.gz ./lamassu-server

24
build/server.Dockerfile Normal file
View file

@ -0,0 +1,24 @@
FROM alpine:3.14 as build
RUN apk add --no-cache nodejs npm git curl build-base net-tools python3 postgresql-dev
WORKDIR lamassu-server
COPY ["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 . ./
FROM alpine:3.14
RUN apk add --no-cache nodejs npm git curl bash libpq openssl
COPY --from=build /lamassu-server /lamassu-server
WORKDIR /lamassu-server/
RUN chmod +x bin/lamassu-server-entrypoint.sh
EXPOSE 3000
ENTRYPOINT [ "/lamassu-server/bin/lamassu-server-entrypoint.sh" ]