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
|
# will have compiled files and executables
|
||||||
/target/
|
/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
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
|
1
.env
1
.env
@ -1,5 +1,4 @@
|
|||||||
DEBUG=true
|
DEBUG=true
|
||||||
NODE_ENV=development
|
|
||||||
RUST_LOG=debug
|
RUST_LOG=debug
|
||||||
JIRS_CLIENT_PORT=7000
|
JIRS_CLIENT_PORT=7000
|
||||||
JIRS_CLIENT_BIND=0.0.0.0
|
JIRS_CLIENT_BIND=0.0.0.0
|
||||||
|
@ -1,11 +1,59 @@
|
|||||||
version: '3.0'
|
version: '3.2'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
ports:
|
environment:
|
||||||
- 5432:5432
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||||
|
|
||||||
server:
|
server:
|
||||||
build:
|
build:
|
||||||
dockerfile: ./jirs-server/Dockerfile
|
dockerfile: ./jirs-server/Dockerfile
|
||||||
context: .
|
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,11 +6,11 @@ server {
|
|||||||
root /home/eraden/code/eraden/jirs/jirs-client/tmp;
|
root /home/eraden/code/eraden/jirs/jirs-client/tmp;
|
||||||
|
|
||||||
location ~ .wasm {
|
location ~ .wasm {
|
||||||
default_type application/wasm;
|
default_type application/wasm;
|
||||||
}
|
}
|
||||||
|
|
||||||
location *.js {
|
location *.js {
|
||||||
default_type application/javascript;
|
default_type application/javascript;
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
@ -6,7 +6,7 @@ rm -Rf build
|
|||||||
mkdir build
|
mkdir build
|
||||||
|
|
||||||
wasm-pack build --mode normal --release --out-name jirs --out-dir ./build --target web
|
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
|
cp -r ./static/* ./build
|
||||||
cat ./static/index.js \
|
cat ./static/index.js \
|
||||||
|
@ -3,13 +3,17 @@ FROM archlinux:latest
|
|||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
|
|
||||||
RUN pacman -Sy rustup gcc postgresql --noconfirm
|
RUN pacman -Sy rustup gcc postgresql --noconfirm
|
||||||
|
|
||||||
ADD jirs-server .
|
|
||||||
ADD jirs-data .
|
|
||||||
|
|
||||||
RUN rustup toolchain install nightly && \
|
RUN rustup toolchain install nightly && \
|
||||||
rustup default nightly && \
|
rustup default nightly
|
||||||
cargo install diesel_cli --no-default-features --features postgres && \
|
|
||||||
cd jirs-server && diesel setup
|
|
||||||
|
|
||||||
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 {
|
impl Default for Configuration {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let database_url = if cfg!(test) {
|
let database_url = if cfg!(test) {
|
||||||
"postgres://postgres@localhost:5432/jirs_test"
|
"postgres://postgres@localhost:5432/jirs_test".to_string()
|
||||||
} else {
|
} else {
|
||||||
"postgres://postgres@localhost:5432/jirs"
|
std::env::var("DATABASE_URL")
|
||||||
}
|
.unwrap_or_else(|_| "postgres://postgres@localhost:5432/jirs".to_string())
|
||||||
.to_string();
|
};
|
||||||
Self {
|
Self {
|
||||||
concurrency: 2,
|
concurrency: 2,
|
||||||
database_url,
|
database_url,
|
||||||
|
Loading…
Reference in New Issue
Block a user