Add docker
This commit is contained in:
parent
6d3268b4a6
commit
4d8a6a7b12
29
.builds/nginx.conf
Normal file
29
.builds/nginx.conf
Normal file
@ -0,0 +1,29 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name jirs.lvh.me;
|
||||
|
||||
charset utf-8;
|
||||
root /assets;
|
||||
|
||||
location ~ .wasm {
|
||||
default_type application/wasm;
|
||||
}
|
||||
|
||||
location *.js {
|
||||
default_type application/javascript;
|
||||
}
|
||||
|
||||
location / {
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
error_page 404 =200 /index.html;
|
||||
|
||||
location /ws/ {
|
||||
proxy_pass http://server:5000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
}
|
@ -77,10 +77,6 @@ fabric.properties
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
|
1
.env
1
.env
@ -1,5 +1,4 @@
|
||||
DEBUG=true
|
||||
NODE_ENV=development
|
||||
RUST_LOG=debug
|
||||
JIRS_CLIENT_PORT=7000
|
||||
JIRS_CLIENT_BIND=0.0.0.0
|
||||
|
@ -1,11 +1,59 @@
|
||||
version: '3.0'
|
||||
version: '3.2'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:latest
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||
|
||||
server:
|
||||
build:
|
||||
dockerfile: ./jirs-server/Dockerfile
|
||||
context: .
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
- DATABASE_URL=postgres://postgres@db/jirs
|
||||
- JIRS_SERVER_PORT=5000
|
||||
- JIRS_SERVER_BIND=0.0.0.0
|
||||
- RUST_LOG=debug
|
||||
- DEBUG=true
|
||||
- JIRS_CLIENT_PORT=7000
|
||||
- JIRS_CLIENT_BIND=0.0.0.0
|
||||
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
depends_on:
|
||||
- client
|
||||
- server
|
||||
ports:
|
||||
- 80:80
|
||||
volumes:
|
||||
- ./.builds/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
- type: volume
|
||||
source: assets
|
||||
target: /assets
|
||||
volume:
|
||||
nocopy: true
|
||||
|
||||
client:
|
||||
build:
|
||||
dockerfile: ./jirs-client/Dockerfile
|
||||
context: .
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- JIRS_SERVER_PORT=80
|
||||
- JIRS_SERVER_BIND=jirs.lvh.me
|
||||
- JIRS_CLIENT_PORT=80
|
||||
- JIRS_CLIENT_BIND=jirs.lvh.me
|
||||
volumes:
|
||||
- type: volume
|
||||
source: assets
|
||||
target: /assets
|
||||
volume:
|
||||
nocopy: true
|
||||
|
||||
volumes:
|
||||
assets:
|
||||
|
5
jirs-client/.dockerignore
Normal file
5
jirs-client/.dockerignore
Normal file
@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
dev
|
||||
pkg
|
||||
tmp
|
||||
target
|
33
jirs-client/Dockerfile
Normal file
33
jirs-client/Dockerfile
Normal file
@ -0,0 +1,33 @@
|
||||
FROM archlinux:latest
|
||||
|
||||
RUN pacman -Sy rustup gcc which --noconfirm
|
||||
|
||||
WORKDIR /app/
|
||||
|
||||
RUN rustup toolchain install nightly && \
|
||||
rustup default nightly && \
|
||||
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||
|
||||
ADD ./jirs-data /app/jirs-data
|
||||
ADD ./jirs-css /app/jirs-css
|
||||
|
||||
RUN cd /app/jirs-css && cargo build --bin jirs-css && cp ./target/debug/jirs-css /bin
|
||||
|
||||
ADD ./jirs-client /app/jirs-client
|
||||
|
||||
RUN cd ./jirs-client && \
|
||||
rm -Rf build && \
|
||||
mkdir build && \
|
||||
wasm-pack build --mode normal --release --out-name jirs --out-dir ./build --target web && \
|
||||
jirs-css -i ./js/styles.css -O ./build/styles.css && \
|
||||
cp -r ./static/* ./build && \
|
||||
cat ./static/index.js \
|
||||
| sed -e "s/process.env.JIRS_SERVER_BIND/'$JIRS_SERVER_BIND'/g" \
|
||||
| sed -e "s/process.env.JIRS_SERVER_PORT/'$JIRS_SERVER_PORT'/g" &> ./build/index.js && \
|
||||
cp ./js/template.html ./build/index.html && \
|
||||
mkdir -p /assets && \
|
||||
cp -r ./build/* /assets
|
||||
|
||||
CMD cat /app/jirs-client/static/index.js \
|
||||
| sed -e "s/process.env.JIRS_SERVER_BIND/'$JIRS_SERVER_BIND'/g" \
|
||||
| sed -e "s/process.env.JIRS_SERVER_PORT/'$JIRS_SERVER_PORT'/g" &> /assets/index.js
|
@ -6,7 +6,7 @@ rm -Rf build
|
||||
mkdir build
|
||||
|
||||
wasm-pack build --mode normal --release --out-name jirs --out-dir ./build --target web
|
||||
../target/debug/jirs-css -i ./js/styles.css -O ./tmp/styles.css
|
||||
../target/debug/jirs-css -i ./js/styles.css -O ./build/styles.css
|
||||
|
||||
cp -r ./static/* ./build
|
||||
cat ./static/index.js \
|
||||
|
@ -3,13 +3,17 @@ FROM archlinux:latest
|
||||
WORKDIR /app/
|
||||
|
||||
RUN pacman -Sy rustup gcc postgresql --noconfirm
|
||||
|
||||
ADD jirs-server .
|
||||
ADD jirs-data .
|
||||
|
||||
RUN rustup toolchain install nightly && \
|
||||
rustup default nightly && \
|
||||
cargo install diesel_cli --no-default-features --features postgres && \
|
||||
cd jirs-server && diesel setup
|
||||
rustup default nightly
|
||||
|
||||
CMD cd jirs-server && cargo run --bin jirs_server
|
||||
RUN cargo install diesel_cli --no-default-features --features postgres
|
||||
|
||||
ADD jirs-server /app/jirs-server
|
||||
ADD jirs-data /app/jirs-data
|
||||
|
||||
RUN pacman -Sy openssl openssh pkgconf --noconfirm
|
||||
RUN pkg-config --libs openssl
|
||||
|
||||
CMD cd /app/jirs-server && \
|
||||
$HOME/.cargo/bin/diesel setup --database-url=$DATABASE_URL && \
|
||||
cargo run --bin jirs_server
|
||||
|
@ -63,11 +63,11 @@ pub struct Configuration {
|
||||
impl Default for Configuration {
|
||||
fn default() -> Self {
|
||||
let database_url = if cfg!(test) {
|
||||
"postgres://postgres@localhost:5432/jirs_test"
|
||||
"postgres://postgres@localhost:5432/jirs_test".to_string()
|
||||
} else {
|
||||
"postgres://postgres@localhost:5432/jirs"
|
||||
}
|
||||
.to_string();
|
||||
std::env::var("DATABASE_URL")
|
||||
.unwrap_or_else(|_| "postgres://postgres@localhost:5432/jirs".to_string())
|
||||
};
|
||||
Self {
|
||||
concurrency: 2,
|
||||
database_url,
|
||||
|
Loading…
Reference in New Issue
Block a user