improve docker build and wait for memcached

This commit is contained in:
cupcakearmy 2022-06-07 12:29:40 +02:00
parent 1d55d7f2d2
commit 9029f72a02
No known key found for this signature in database
GPG Key ID: 3235314B4D31232F
3 changed files with 37 additions and 18 deletions

View File

@ -1,2 +1,15 @@
/**/target
/**/node_modules
*
!/entry.sh
!/backend/src
!/backend/Cargo.lock
!/backend/Cargo.toml
!/frontend/locales
!/frontend/src
!/frontend/static
!/frontend/.npmrc
!/frontend/package.json
!/frontend/pnpm-lock.yaml
!/frontend/svelte.config.js
!/frontend/tsconfig.json

View File

@ -1,31 +1,26 @@
# Frontend
FROM node:16-alpine as CLIENT
# FRONTEND
FROM node:16-alpine as client
WORKDIR /tmp
COPY ./frontend ./
RUN npm install -g pnpm
COPY ./frontend ./
RUN pnpm install
RUN pnpm run build
# Backend
FROM rust:1.59-alpine as RUST
# BACKEND
FROM rust:1.61-alpine as backend
WORKDIR /tmp
RUN apk add libc-dev openssl-dev alpine-sdk
COPY ./backend ./
RUN cargo build --release
# Server
# RUNNER
FROM alpine
WORKDIR /app
COPY --from=RUST /tmp/target/release/cryptgeon .
COPY --from=CLIENT /tmp/build ./frontend/build
COPY ./entry.sh .
COPY --from=backend /tmp/target/release/cryptgeon .
COPY --from=client /tmp/build ./frontend/build
ENV MEMCACHE=memcached:11211
EXPOSE 5000
ENTRYPOINT [ "/app/cryptgeon" ]
ENTRYPOINT [ "/app/entry.sh" ]

11
entry.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/ash
echo "Waiting for memcached"
while ! nc -z -w 1 memcached 11211; do
sleep 1
echo "..."
done
echo "Starting server"
/app/cryptgeon