mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
code sharing sample: flat package directory (#1486)
This commit is contained in:
@@ -1,9 +1,15 @@
|
|||||||
# Use latest stable channel SDK.
|
# Use latest stable channel SDK.
|
||||||
FROM dart:stable AS build
|
FROM dart:stable AS build
|
||||||
|
|
||||||
|
# Copy shared code.
|
||||||
|
WORKDIR /shared
|
||||||
|
COPY /shared/. .
|
||||||
|
|
||||||
|
# Copy server code.
|
||||||
|
WORKDIR /server
|
||||||
|
COPY /server/. .
|
||||||
|
|
||||||
# Resolve app dependencies.
|
# Resolve app dependencies.
|
||||||
WORKDIR /app
|
|
||||||
COPY . .
|
|
||||||
RUN dart pub get
|
RUN dart pub get
|
||||||
|
|
||||||
# AOT compile app.
|
# AOT compile app.
|
||||||
@@ -13,7 +19,7 @@ RUN dart compile exe bin/server.dart -o bin/server
|
|||||||
# and the pre-built AOT-runtime in the `/runtime/` directory of the base image.
|
# and the pre-built AOT-runtime in the `/runtime/` directory of the base image.
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=build /runtime/ /
|
COPY --from=build /runtime/ /
|
||||||
COPY --from=build /app/bin/server /app/bin/
|
COPY --from=build /server/bin/server /app/bin/
|
||||||
|
|
||||||
# Start server.
|
# Start server.
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
@@ -19,6 +19,6 @@ test:
|
|||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
build:
|
build:
|
||||||
(cd server && flutter pub get)
|
(cd server && dart pub get)
|
||||||
docker build ./server -t codesharingserver -f server/Dockerfile
|
docker build . -t codesharingserver
|
||||||
|
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ code_sharing/
|
|||||||
server/
|
server/
|
||||||
bin/
|
bin/
|
||||||
server.dart
|
server.dart
|
||||||
|
pubspec.yaml
|
||||||
|
Dockerfile
|
||||||
# Common business logic
|
# Common business logic
|
||||||
shared/
|
shared/
|
||||||
pubspec.yaml
|
pubspec.yaml
|
||||||
lib/
|
lib/
|
||||||
...
|
...
|
||||||
pubspec.yaml
|
|
||||||
Dockerfile
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Recreating this on your own
|
## Recreating this on your own
|
||||||
|
|||||||
@@ -78,7 +78,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
(int val) => setState(
|
(int val) => setState(
|
||||||
() {
|
() {
|
||||||
_counter = val;
|
_counter = val;
|
||||||
isWriting = true;
|
// Leave this up for at least a split second
|
||||||
|
Future.delayed(
|
||||||
|
const Duration(milliseconds: 200),
|
||||||
|
() => setState(() => isWriting = false),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ dependencies:
|
|||||||
sdk: flutter
|
sdk: flutter
|
||||||
http: ^0.13.5
|
http: ^0.13.5
|
||||||
shared:
|
shared:
|
||||||
path: ../server/shared
|
path: ../shared
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^2.0.0
|
flutter_lints: ^2.0.0
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ version: "3.7"
|
|||||||
services:
|
services:
|
||||||
server:
|
server:
|
||||||
build:
|
build:
|
||||||
context: server
|
context: .
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
.dockerignore
|
.dockerignore
|
||||||
Dockerfile
|
Dockerfile
|
||||||
build/
|
docker-compose.yml
|
||||||
.dart_tool/
|
Makefile
|
||||||
|
README.md
|
||||||
|
*/build/
|
||||||
|
*/.dart_tool/
|
||||||
.git/
|
.git/
|
||||||
.github/
|
.github/
|
||||||
.gitignore
|
.gitignore
|
||||||
.idea/
|
*/.idea/
|
||||||
.packages
|
*/.packages
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ dependencies:
|
|||||||
shelf: ^1.1.0
|
shelf: ^1.1.0
|
||||||
shelf_router: ^1.0.0
|
shelf_router: ^1.0.0
|
||||||
shared:
|
shared:
|
||||||
path: ./shared
|
path: ../shared
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
http: ^0.13.0
|
http: ^0.13.0
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ declare -ar PROJECT_NAMES=(
|
|||||||
"animations"
|
"animations"
|
||||||
"code_sharing/client"
|
"code_sharing/client"
|
||||||
"code_sharing/server"
|
"code_sharing/server"
|
||||||
"code_sharing/server/shared"
|
"code_sharing/shared"
|
||||||
"desktop_photo_search/fluent_ui"
|
"desktop_photo_search/fluent_ui"
|
||||||
"desktop_photo_search/material"
|
"desktop_photo_search/material"
|
||||||
"experimental/federated_plugin/federated_plugin"
|
"experimental/federated_plugin/federated_plugin"
|
||||||
|
|||||||
Reference in New Issue
Block a user