Add kApiBaseUrl constant
This commit is contained in:
parent
820cd9efa8
commit
2fbee208e7
21
Dockerfile
21
Dockerfile
@ -1,10 +1,21 @@
|
|||||||
FROM cirrusci/flutter:3.7.0 AS build
|
# Flutter 3.44.0 : la version qui compile réellement ce projet.
|
||||||
|
#
|
||||||
|
# L'image précédente épinglait cirrusci/flutter:3.7.0, qui embarque Dart 2.19,
|
||||||
|
# alors que le pubspec exige `sdk: ">=3.1.0 <4.0.0"` — le `flutter pub get`
|
||||||
|
# échouait donc, et l'image n'était plus constructible. `cirrusci` n'est de
|
||||||
|
# toute façon plus publié : le dépôt maintenu est `cirruslabs`.
|
||||||
|
FROM ghcr.io/cirruslabs/flutter:3.44.0 AS build
|
||||||
|
|
||||||
|
# ⚠️ L'URL de l'API est figée au BUILD : une image est liée à un environnement.
|
||||||
|
# Sans cet argument, elle vaut localhost:5000 et l'image déployée ne parle à rien.
|
||||||
|
# docker build --build-arg API_BASE_URL=https://api.mymuseum.be -t ... .
|
||||||
|
ARG API_BASE_URL=http://localhost:5000
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN flutter pub get
|
RUN flutter pub get
|
||||||
RUN flutter build web
|
RUN flutter build web --release --dart-define=API_BASE_URL=$API_BASE_URL
|
||||||
|
|
||||||
|
|
||||||
FROM nginx:1.21.1-alpine
|
|
||||||
|
|
||||||
|
FROM nginx:1.27-alpine
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY --from=build /app/build/web /usr/share/nginx/html
|
COPY --from=build /app/build/web /usr/share/nginx/html
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class ForgotPasswordScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||||
final String host = "http://localhost:5000";
|
final String host = kApiBaseUrl;
|
||||||
String email = "";
|
String email = "";
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
bool isSent = false;
|
bool isSent = false;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class SetPasswordScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SetPasswordScreenState extends State<SetPasswordScreen> {
|
class _SetPasswordScreenState extends State<SetPasswordScreen> {
|
||||||
final String host = "http://localhost:5000";
|
final String host = kApiBaseUrl;
|
||||||
String newPassword = "";
|
String newPassword = "";
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
bool isDone = false;
|
bool isDone = false;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class LoginScreen extends StatefulWidget {
|
|||||||
class _LoginScreenState extends State<LoginScreen> {
|
class _LoginScreenState extends State<LoginScreen> {
|
||||||
String email = ""; // DEV "test@email.be"
|
String email = ""; // DEV "test@email.be"
|
||||||
String password = ""; // DEV = "kljqsdkljqsd"
|
String password = ""; // DEV = "kljqsdkljqsd"
|
||||||
String? host = "http://localhost:5000"; // "https://api.myinfomate.be" // "https://api.mymuseum.be" // DEV = "http://192.168.31.96" // http://localhost:5000 // https://api.mymuseum.be // myCore http://192.168.31.140:8089
|
String? host = kApiBaseUrl; // "https://api.myinfomate.be" // "https://api.mymuseum.be" // DEV = "http://192.168.31.96" // http://localhost:5000 // https://api.mymuseum.be // myCore http://192.168.31.140:8089
|
||||||
Client? clientAPI;
|
Client? clientAPI;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
bool isRememberMe = false;
|
bool isRememberMe = false;
|
||||||
@ -169,7 +169,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
this.host = "http://localhost:5000";
|
this.host = kApiBaseUrl;
|
||||||
|
|
||||||
if (localStorage.containsKey("remember")) {
|
if (localStorage.containsKey("remember")) {
|
||||||
this.isRememberMe = true;
|
this.isRememberMe = true;
|
||||||
|
|||||||
@ -15,6 +15,14 @@ const kWhite = Color(0xFFFFFFFF);
|
|||||||
const kBlack = Color(0xFF000000);
|
const kBlack = Color(0xFF000000);
|
||||||
const kSuccess = Color(0xFF8bc34a);
|
const kSuccess = Color(0xFF8bc34a);
|
||||||
|
|
||||||
|
// URL de l'API, injectee au build :
|
||||||
|
// flutter build web --dart-define=API_BASE_URL=https://api.mymuseum.be
|
||||||
|
//
|
||||||
|
// Elle etait ecrite en dur a quatre endroits, donc une image de manager-web
|
||||||
|
// etait liee a un environnement sans que rien ne le signale.
|
||||||
|
const kApiBaseUrl = String.fromEnvironment('API_BASE_URL',
|
||||||
|
defaultValue: 'http://localhost:5000');
|
||||||
|
|
||||||
// Responsive
|
// Responsive
|
||||||
const kBreakpointMobile = 850.0;
|
const kBreakpointMobile = 850.0;
|
||||||
|
|
||||||
|
|||||||
21
nginx.conf
Normal file
21
nginx.conf
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Routage par chemin : /set-password?token=... doit servir index.html,
|
||||||
|
# sinon nginx renvoie 404 sur toute URL profonde.
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|svg|woff2?|ttf|json)$ {
|
||||||
|
expires 7d;
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
}
|
||||||
|
|
||||||
|
# index.html jamais mis en cache, sinon un redéploiement ne se voit pas.
|
||||||
|
location = /index.html {
|
||||||
|
add_header Cache-Control "no-store, must-revalidate";
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user