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.
|
||||
FROM dart:stable AS build
|
||||
|
||||
# Copy shared code.
|
||||
WORKDIR /shared
|
||||
COPY /shared/. .
|
||||
|
||||
# Copy server code.
|
||||
WORKDIR /server
|
||||
COPY /server/. .
|
||||
|
||||
# Resolve app dependencies.
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN dart pub get
|
||||
|
||||
# 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.
|
||||
FROM scratch
|
||||
COPY --from=build /runtime/ /
|
||||
COPY --from=build /app/bin/server /app/bin/
|
||||
COPY --from=build /server/bin/server /app/bin/
|
||||
|
||||
# Start server.
|
||||
EXPOSE 8080
|
||||
@@ -19,6 +19,6 @@ test:
|
||||
|
||||
# Docker
|
||||
build:
|
||||
(cd server && flutter pub get)
|
||||
docker build ./server -t codesharingserver -f server/Dockerfile
|
||||
(cd server && dart pub get)
|
||||
docker build . -t codesharingserver
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ code_sharing/
|
||||
server/
|
||||
bin/
|
||||
server.dart
|
||||
# Common business logic
|
||||
shared/
|
||||
pubspec.yaml
|
||||
lib/
|
||||
...
|
||||
pubspec.yaml
|
||||
Dockerfile
|
||||
# Common business logic
|
||||
shared/
|
||||
pubspec.yaml
|
||||
lib/
|
||||
...
|
||||
```
|
||||
|
||||
## Recreating this on your own
|
||||
|
||||
@@ -78,7 +78,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
(int val) => setState(
|
||||
() {
|
||||
_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
|
||||
http: ^0.13.5
|
||||
shared:
|
||||
path: ../server/shared
|
||||
path: ../shared
|
||||
|
||||
dev_dependencies:
|
||||
flutter_lints: ^2.0.0
|
||||
|
||||
@@ -2,7 +2,7 @@ version: "3.7"
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
context: server
|
||||
context: .
|
||||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
build/
|
||||
.dart_tool/
|
||||
docker-compose.yml
|
||||
Makefile
|
||||
README.md
|
||||
*/build/
|
||||
*/.dart_tool/
|
||||
.git/
|
||||
.github/
|
||||
.gitignore
|
||||
.idea/
|
||||
.packages
|
||||
*/.idea/
|
||||
*/.packages
|
||||
|
||||
@@ -11,7 +11,7 @@ dependencies:
|
||||
shelf: ^1.1.0
|
||||
shelf_router: ^1.0.0
|
||||
shared:
|
||||
path: ./shared
|
||||
path: ../shared
|
||||
|
||||
dev_dependencies:
|
||||
http: ^0.13.0
|
||||
|
||||
Reference in New Issue
Block a user