File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5757
5858 # target:
5959
60- # platforms: linux/amd64
60+ platforms : linux/amd64,linux/arm64
6161
6262 # comment-enable: true
Original file line number Diff line number Diff line change @@ -43,24 +43,19 @@ COPY ./frontend .
4343
4444RUN --mount=type=cache,target=/root/.npm \
4545 npm ci --verbose --no-audit
46+
47+ # don't include any frontend custom config
48+ RUN rm .env
49+
4650# This should be npm run build
4751RUN npx vite build
4852
4953FROM debian:bookworm-slim AS runtime
5054
5155WORKDIR /app
5256
53- RUN apt-get update && apt-get install -y libssl-dev openssl curl pkg-config ca-certificates nginx postgresql tini gcc
54-
55- # install sqlx-cli to handle database migrations
56- RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
57- ENV PATH="/root/.cargo/bin:${PATH}"
58- RUN cargo install sqlx-cli
59-
60- COPY ./backend/migrations/ /migrations
61-
62- COPY ./docker/initdb.sh /
63- RUN chmod +x /initdb.sh
57+ RUN apt-get update && apt-get install --no-install-recommends -y libssl-dev openssl curl pkg-config ca-certificates nginx tini
58+ RUN apt-get clean && rm -rf /var/lib/apt/lists/*
6459
6560COPY --from=builder_backend /usr/local/bin/dasharr_backend /usr/local/bin
6661
@@ -75,7 +70,6 @@ EXPOSE 80
7570ENTRYPOINT ["/usr/bin/tini" , "--" ]
7671
7772CMD ["sh" , "-c" , "\
78- cd / && /initdb.sh && \
7973 cd /usr/local/bin/ && ./dasharr_backend & \
8074 nginx -g 'daemon off;' & \
8175 wait" ]
Original file line number Diff line number Diff line change 1212RUST_LOG = " info,sqlx=info"
1313
1414# port on which the api will be listening
15- # if using docker, do not change it , everything goes through nginx
16- # which redirects api calls to this port
15+ # if using docker, DO NOT CHANGE IT , everything goes through nginx (port 80 in the container)
16+ # which redirects api calls (everything on /api) to this port
1717WEB_SERVER_PORT = 8080
1818
1919POSTGRES_USER = dasharr
2020POSTGRES_PASSWORD = password
21- POSTGRES_HOST = localhost
21+
22+ # if using regular installation:
23+ # POSTGRES_HOST=localhost
2224# if using docker:
23- # POSTGRES_HOST=db
25+ POSTGRES_HOST = db
26+
2427POSTGRES_PORT = 5432
2528POSTGRES_DB = dasharr
2629
Original file line number Diff line number Diff line change 11use sqlx:: { PgPool , postgres:: PgPoolOptions } ;
2- use std:: borrow:: { Borrow , BorrowMut } ;
2+ use std:: {
3+ borrow:: { Borrow , BorrowMut } ,
4+ ops:: Deref ,
5+ } ;
36
47pub struct ConnectionPool ( PgPool ) ;
58
@@ -30,3 +33,10 @@ impl BorrowMut<PgPool> for ConnectionPool {
3033 & mut self . 0
3134 }
3235}
36+
37+ impl Deref for ConnectionPool {
38+ type Target = PgPool ;
39+ fn deref ( & self ) -> & Self :: Target {
40+ & self . 0
41+ }
42+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ use dasharr::{
55 scheduler:: run_periodic_tasks,
66} ;
77use envconfig:: Envconfig ;
8+ use std:: borrow:: Borrow ;
9+ use std:: ops:: Deref ;
810use std:: { env, sync:: Arc } ;
911use utoipa:: OpenApi ;
1012use utoipa_swagger_ui:: SwaggerUi ;
@@ -22,6 +24,11 @@ async fn main() -> std::io::Result<()> {
2224 . expect ( "db connection couldn't be established" ) ,
2325 ) ;
2426
27+ sqlx:: migrate!( "./migrations" )
28+ . run ( pool. deref ( ) . borrow ( ) )
29+ . await
30+ . expect ( "Failed to run database migrations!" ) ;
31+
2532 let arc = Data :: new ( Dasharr :: new ( Arc :: clone ( & pool) , env. clone ( ) ) ) ;
2633
2734 let web_server_port = env:: var ( "WEB_SERVER_PORT" ) . expect ( "WEB_SERVER_PORT must be set" ) ;
You can’t perform that action at this time.
0 commit comments