Browse Source

first commit

master
Xsivax 3 years ago
commit
7386dbaed5
8 changed files with 152 additions and 0 deletions
  1. +16
    -0
      README.md
  2. +1
    -0
      build/deb-rust/.env
  3. +24
    -0
      build/deb-rust/Dockerfile
  4. +11
    -0
      build/deb-rust/Makefile
  5. +7
    -0
      build/deb-rust/Rocket.toml
  6. +47
    -0
      compose/docker-compose.yml
  7. +21
    -0
      compose/docker-compose.yml.save
  8. +25
    -0
      run.sh

+ 16
- 0
README.md View File

@ -0,0 +1,16 @@
Build and run :
. run.sh
terminate with :
Ctrl-C
then:
cd ..

+ 1
- 0
build/deb-rust/.env View File

@ -0,0 +1 @@
DATABASE_URL=mysql://rocket_user:rocket_pw@mariadb/rocket_db

+ 24
- 0
build/deb-rust/Dockerfile View File

@ -0,0 +1,24 @@
FROM rustlang/rust:nightly
WORKDIR /usr/src
RUN apt-get update
RUN git clone https://basabuuka.zapto.org/xsiva/rocket-3d.git
RUN cargo install --path ./rocket-3d
WORKDIR /usr/src/rocket-3d
COPY Rocket.toml /usr/src/rocket-3d/Rocket.toml
COPY .env /usr/src/rocket-3d/.env
RUN cargo install cargo-watch
# RUN cargo install diesel_cli --no-default-features --features "mysql"
# RUN diesel setup
CMD ROCKET_ENV=debug cargo watch -x 'run --bin rocket-3d'

+ 11
- 0
build/deb-rust/Makefile View File

@ -0,0 +1,11 @@
local_build:
docker build -t rocket_local_dev -f Dockerfile .
local_run:
docker run --rm -it -p 5000:5000 --mount source="$(shell pwd)",target=/usr/src,type=bind --name rocket-server rocket_local_dev cargo watch -x 'run --bin rocket-3d'
local_stop:
docker stop rocket
local_shell:
docker run --rm -it -p 5000:5000 --mount source="$(shell pwd)",target=/usr/src,type=bind --name rocket-server rocket_local_dev

+ 7
- 0
build/deb-rust/Rocket.toml View File

@ -0,0 +1,7 @@
[debug]
address = "0.0.0.0"
port = 5000
[default]
template_dir = "templates"

+ 47
- 0
compose/docker-compose.yml View File

@ -0,0 +1,47 @@
version: "3.4"
services:
deb-rust:
container_name: deb-rust
restart: always
build: ../build/deb-rust
environment:
- RUST_BACKTRACE=1
- DATABASE_URL=mysql://rocket_user:rocket_pw@0.0.0.0:3306/rocket_db
ports:
- "5000:5000"
networks:
- rocket-db
#depends_on:
#- mariadb
#links:
#- "mariadb"
#mariadb:
#image: mariadb:latest
#container_name: mariadb
#hostname: mariadb
#restart: always
#volumes:
#- "mariadb_vol:/var/lib/mysql"
#ports:
#- "3306:3306"
#environment:
#- MYSQL_ROOT_PASSWORD=password
#- MYSQL_PASSWORD=rocket_pw
#- MYSQL_DATABASE=rocket_db
#- MYSQL_USER=rocket_user
#networks:
#- rocket-db
networks:
rocket-db:
driver: bridge
volumes:
maria-data:
driver: local
mariadb_vol:

+ 21
- 0
compose/docker-compose.yml.save View File

@ -0,0 +1,21 @@
version: "3.4"
services:
deb-rust-rocket:
container_name: "deb-rust-rocket"
command: cargo watch -x 'run --bin rocket-3d'
build:
dockerfile: Dockerfile
context: ../build/deb-rust
cache_from:
- rustlang/rust:nightly
networks:
- library-network
tty: true
wq
volumes:
- type: bind
source: ./
target: /usr/src
ports:
- "5000:5000"

+ 25
- 0
run.sh View File

@ -0,0 +1,25 @@
#!/bin/bash
trap "cd '..'" TERM INT
# run docker-container
run() {
cd "compose" && \
docker-compose build --no-cache deb-rust && \
docker-compose up && \
}
run
#to do:
# ctrl-c(sigint):
# stop and remove container(with custom message)
# cd ..

Loading…
Cancel
Save