This commit is contained in:
cupcakearmy 2021-05-02 13:53:48 +02:00
parent 25d5590ceb
commit ab0166c5ac
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9
6 changed files with 42 additions and 4 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
target

View File

@ -4,6 +4,10 @@ version = "1.0.0"
authors = ["cupcakearmy <hi@nicco.io>"]
edition = "2018"
[[bin]]
name = "cryptgeon"
path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

26
Dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM node:16-alpine as CLIENT
WORKDIR /tmp
COPY ./client .
RUN npm ci
RUN npm run build
FROM rust:1.51-alpine as RUST
WORKDIR /tmp
RUN apk add libc-dev openssl-dev alpine-sdk
COPY ./Cargo* .
COPY ./src ./src
RUN cargo build --release
FROM alpine
WORKDIR /app
COPY --from=RUST /tmp/target/release/cryptgeon .
COPY --from=CLIENT /tmp/build ./client/build
ENV MEMCACHE=memcached:11211
ENTRYPOINT [ "/app/cryptgeon" ]

View File

@ -6,3 +6,8 @@ services:
entrypoint: memcached -m 128
ports:
- 11211:11211
app:
build: .
ports:
- 80:5000

View File

@ -13,12 +13,11 @@ async fn main() -> std::io::Result<()> {
App::new()
.wrap(middleware::Compress::default())
.wrap(middleware::DefaultHeaders::default())
// .wrap(middleware::NormalizePath::default())
.configure(note::init)
.configure(client::init)
.default_service(web::resource("").route(web::get().to(client::fallback_fn)))
})
.bind("127.0.0.1:5000")?
.bind("0.0.0.0:5000")?
.run()
.await
}

View File

@ -3,8 +3,11 @@ use memcache;
use crate::note::Note;
lazy_static! {
static ref CLIENT: memcache::Client =
memcache::connect("memcache://127.0.0.1:11211?timeout=10&tcp_nodelay=true").unwrap();
static ref CLIENT: memcache::Client = memcache::connect(format!(
"memcache://{}?timeout=10&tcp_nodelay=true",
std::env::var("MEMCACHE").unwrap_or("127.0.0.1:11211".to_string())
))
.unwrap();
}
pub fn set(id: &String, note: &Note) {