execución en docker
This commit is contained in:
parent
9f82a67b9b
commit
2cc98bb908
38
Dockerfile
Normal file
38
Dockerfile
Normal file
@ -0,0 +1,38 @@
|
||||
################################################################################
|
||||
## BUILDER
|
||||
################################################################################
|
||||
FROM rust:slim as builder
|
||||
|
||||
# para compilación estática sin libc
|
||||
ENV TARGET x86_64-unknown-linux-musl
|
||||
RUN rustup target add "$TARGET"
|
||||
|
||||
# xeneracion do executable
|
||||
RUN USER=root mkdir ./itkg
|
||||
WORKDIR ./itkg
|
||||
ADD . ./
|
||||
RUN cargo build --release --locked --target "$TARGET" \
|
||||
&& mv "target/$TARGET/release/itkg" . \
|
||||
&& strip itkg
|
||||
|
||||
# usuario para execucion
|
||||
RUN groupadd app && useradd -g app app
|
||||
|
||||
################################################################################
|
||||
## RUNER
|
||||
################################################################################
|
||||
FROM scratch
|
||||
ARG APP=/app
|
||||
|
||||
EXPOSE 3007
|
||||
|
||||
COPY --from=builder /etc/passwd /etc/passwd
|
||||
COPY --from=builder /etc/group /etc/group
|
||||
|
||||
COPY --from=builder --chown=app:app /itkg/itkg ${APP}/itkg
|
||||
COPY --from=builder --chown=app:app /itkg/templates/ ${APP}/templates/
|
||||
|
||||
USER app
|
||||
WORKDIR ${APP}
|
||||
|
||||
CMD ["./itkg"]
|
14
README.md
14
README.md
@ -6,3 +6,17 @@ La idea es tener en una web los generadores de personajes, naves, monstruos, etc
|
||||
```
|
||||
TEMPLATES="templates" PORT="3007" cargo run
|
||||
```
|
||||
|
||||
### Docker
|
||||
Para executar en docker hai que cambiar a app para que escoite en 0.0.0.0 en vez
|
||||
de en 127.0.0.1
|
||||
|
||||
```
|
||||
docker build -t generadores-itk -f Dockerfile .
|
||||
docker run \
|
||||
--rm \
|
||||
-e TEMPLATES="templates" \
|
||||
-e PORT="3007" \
|
||||
-p 3007:3007 \
|
||||
generadores-itk
|
||||
```
|
||||
|
@ -18,6 +18,7 @@ async fn main() {
|
||||
|
||||
// executase con hyper a través de axum::Server
|
||||
let addr = SocketAddr::from(([127, 0, 0, 1], itkg_lib::env_listen_port()));
|
||||
// let addr = SocketAddr::from(([0, 0, 0, 0], itkg_lib::env_listen_port()));
|
||||
tracing::debug!("listening on {}", addr);
|
||||
axum::Server::bind(&addr)
|
||||
.serve(app.into_make_service())
|
||||
|
Loading…
Reference in New Issue
Block a user