docker image

This commit is contained in:
cupcakearmy 2022-07-14 00:26:07 +02:00
parent 8d5e348f56
commit 0e47dab6d4
No known key found for this signature in database
GPG Key ID: 3235314B4D31232F
4 changed files with 11 additions and 18 deletions

View File

@ -1,5 +1,4 @@
*
!/entry.sh
!/backend/src
!/backend/Cargo.lock
@ -13,3 +12,4 @@
!/frontend/pnpm-lock.yaml
!/frontend/svelte.config.js
!/frontend/tsconfig.json
!/frontend/vite.config.js

View File

@ -1,7 +1,7 @@
# FRONTEND
FROM node:16-alpine as client
WORKDIR /tmp
RUN npm install -g pnpm
RUN npm install -g pnpm@7
COPY ./frontend ./
RUN pnpm install
RUN pnpm run build
@ -18,9 +18,8 @@ RUN cargo build --release
# RUNNER
FROM alpine
WORKDIR /app
COPY ./entry.sh .
COPY --from=backend /tmp/target/release/cryptgeon .
COPY --from=client /tmp/build ./frontend/build
ENV REDIS=redis://redis/
EXPOSE 5000
ENTRYPOINT [ "/app/entry.sh" ]
ENTRYPOINT [ "/app/cryptgeon" ]

View File

@ -4,9 +4,16 @@ use redis::Commands;
use crate::note::now;
use crate::note::Note;
lazy_static! {
static ref REDIS_CLIENT: String = std::env::var("REDIS")
.unwrap_or("redis://127.0.0.1/".to_string())
.parse()
.unwrap();
}
fn get_connection() -> Result<redis::Connection, &'static str> {
let client =
redis::Client::open("redis://127.0.0.1/").map_err(|_| "Unable to connect to redis")?;
redis::Client::open(REDIS_CLIENT.to_string()).map_err(|_| "Unable to connect to redis")?;
client
.get_connection()
.map_err(|_| "Unable to connect to redis")

View File

@ -1,13 +0,0 @@
#!/bin/sh
HOST=$(echo $MEMCACHE | cut -d: -f1)
PORT=$(echo $MEMCACHE | cut -d: -f2)
echo "Waiting for memcached at $HOST:$PORT"
while ! nc -z -w 1 $HOST $PORT; do
sleep 1
echo "retrying..."
done
echo "Starting server"
/app/cryptgeon