mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-12-22 08:16:28 +00:00
docker
This commit is contained in:
parent
25d5590ceb
commit
ab0166c5ac
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
target
|
@ -4,6 +4,10 @@ version = "1.0.0"
|
|||||||
authors = ["cupcakearmy <hi@nicco.io>"]
|
authors = ["cupcakearmy <hi@nicco.io>"]
|
||||||
edition = "2018"
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
26
Dockerfile
Normal file
26
Dockerfile
Normal 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" ]
|
@ -6,3 +6,8 @@ services:
|
|||||||
entrypoint: memcached -m 128
|
entrypoint: memcached -m 128
|
||||||
ports:
|
ports:
|
||||||
- 11211:11211
|
- 11211:11211
|
||||||
|
|
||||||
|
app:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- 80:5000
|
||||||
|
@ -13,12 +13,11 @@ async fn main() -> std::io::Result<()> {
|
|||||||
App::new()
|
App::new()
|
||||||
.wrap(middleware::Compress::default())
|
.wrap(middleware::Compress::default())
|
||||||
.wrap(middleware::DefaultHeaders::default())
|
.wrap(middleware::DefaultHeaders::default())
|
||||||
// .wrap(middleware::NormalizePath::default())
|
|
||||||
.configure(note::init)
|
.configure(note::init)
|
||||||
.configure(client::init)
|
.configure(client::init)
|
||||||
.default_service(web::resource("").route(web::get().to(client::fallback_fn)))
|
.default_service(web::resource("").route(web::get().to(client::fallback_fn)))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:5000")?
|
.bind("0.0.0.0:5000")?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,11 @@ use memcache;
|
|||||||
use crate::note::Note;
|
use crate::note::Note;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref CLIENT: memcache::Client =
|
static ref CLIENT: memcache::Client = memcache::connect(format!(
|
||||||
memcache::connect("memcache://127.0.0.1:11211?timeout=10&tcp_nodelay=true").unwrap();
|
"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) {
|
pub fn set(id: &String, note: &Note) {
|
||||||
|
Loading…
Reference in New Issue
Block a user