From 4a27be33f595ea128421e09f0e72522cb2933983 Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Sat, 10 Aug 2024 11:21:55 +0100 Subject: [PATCH] feat: dockerfile publishing on release-10 branch --- .github/workflows/docker-build.yml | 60 ++++++++++++++++++++++++++++++ build/admin-server.Dockerfile | 40 -------------------- build/server.Dockerfile | 28 ++++++++++++-- lib/app.js | 2 +- 4 files changed, 86 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/docker-build.yml delete mode 100644 build/admin-server.Dockerfile diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..4260e04f --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,60 @@ +name: Docker Build and Publish + +on: + push: + branches: + - release-10.0 + +env: + DOCKERHUB_SERVER_REPO: lamassu/lamassu-server + DOCKERHUB_ADMIN_REPO: lamassu/lamassu-admin-server + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-updatetar + restore-keys: | + ${{ runner.os }}-buildx-updatetar + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + target: l-s + tags: ${{ env.DOCKERHUB_SERVER_REPO }}:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + target: l-a-s + tags: ${{ env.DOCKERHUB_ADMIN_REPO }}:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file diff --git a/build/admin-server.Dockerfile b/build/admin-server.Dockerfile deleted file mode 100644 index f1d263b3..00000000 --- a/build/admin-server.Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -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" ] \ No newline at end of file diff --git a/build/server.Dockerfile b/build/server.Dockerfile index ae99c479..882b131b 100644 --- a/build/server.Dockerfile +++ b/build/server.Dockerfile @@ -10,15 +10,37 @@ RUN npm install --production COPY . ./ -FROM alpine:3.14 +FROM alpine:3.14 as l-s-base 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 +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 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 l-s-base as l-a-s +COPY --from=build-ui /build /lamassu-server/public + +EXPOSE 443 + +ENTRYPOINT [ "node" ] +CMD [ "/lamassu-server/bin/lamassu-admin-server" ] diff --git a/lib/app.js b/lib/app.js index 4e84080f..a6e59100 100644 --- a/lib/app.js +++ b/lib/app.js @@ -46,8 +46,8 @@ function run () { .catch(errorHandler) } - runner() handler = setInterval(runner, 10000) + runner() }) }) }