code sharing sample: flat package directory (#1486)

pull/1489/head
Kevin Moore 2 years ago committed by GitHub
parent c21fcd6573
commit 6caaa0a3c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
# Common business logic
shared/
pubspec.yaml
lib/
...
pubspec.yaml pubspec.yaml
Dockerfile Dockerfile
# Common business logic
shared/
pubspec.yaml
lib/
...
``` ```
## 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"

Loading…
Cancel
Save