Skip to content

Commit 6caaa0a

Browse files
authored
code sharing sample: flat package directory (#1486)
1 parent c21fcd6 commit 6caaa0a

19 files changed

+32
-19
lines changed

code_sharing/server/Dockerfile renamed to code_sharing/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Use latest stable channel SDK.
22
FROM dart:stable AS build
33

4+
# Copy shared code.
5+
WORKDIR /shared
6+
COPY /shared/. .
7+
8+
# Copy server code.
9+
WORKDIR /server
10+
COPY /server/. .
11+
412
# Resolve app dependencies.
5-
WORKDIR /app
6-
COPY . .
713
RUN dart pub get
814

915
# AOT compile app.
@@ -13,7 +19,7 @@ RUN dart compile exe bin/server.dart -o bin/server
1319
# and the pre-built AOT-runtime in the `/runtime/` directory of the base image.
1420
FROM scratch
1521
COPY --from=build /runtime/ /
16-
COPY --from=build /app/bin/server /app/bin/
22+
COPY --from=build /server/bin/server /app/bin/
1723

1824
# Start server.
1925
EXPOSE 8080

code_sharing/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ test:
1919

2020
# Docker
2121
build:
22-
(cd server && flutter pub get)
23-
docker build ./server -t codesharingserver -f server/Dockerfile
22+
(cd server && dart pub get)
23+
docker build . -t codesharingserver
2424

code_sharing/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ code_sharing/
3232
server/
3333
bin/
3434
server.dart
35-
# Common business logic
36-
shared/
37-
pubspec.yaml
38-
lib/
39-
...
4035
pubspec.yaml
4136
Dockerfile
37+
# Common business logic
38+
shared/
39+
pubspec.yaml
40+
lib/
41+
...
4242
```
4343

4444
## Recreating this on your own

code_sharing/client/lib/main.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ class _MyHomePageState extends State<MyHomePage> {
7878
(int val) => setState(
7979
() {
8080
_counter = val;
81-
isWriting = true;
81+
// Leave this up for at least a split second
82+
Future.delayed(
83+
const Duration(milliseconds: 200),
84+
() => setState(() => isWriting = false),
85+
);
8286
},
8387
),
8488
);

code_sharing/client/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
sdk: flutter
1313
http: ^0.13.5
1414
shared:
15-
path: ../server/shared
15+
path: ../shared
1616

1717
dev_dependencies:
1818
flutter_lints: ^2.0.0

code_sharing/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.7"
22
services:
33
server:
44
build:
5-
context: server
5+
context: .
66
ports:
77
- 8080:8080
88
environment:

code_sharing/server/.dockerignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
.dockerignore
22
Dockerfile
3-
build/
4-
.dart_tool/
3+
docker-compose.yml
4+
Makefile
5+
README.md
6+
*/build/
7+
*/.dart_tool/
58
.git/
69
.github/
710
.gitignore
8-
.idea/
9-
.packages
11+
*/.idea/
12+
*/.packages

code_sharing/server/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
shelf: ^1.1.0
1212
shelf_router: ^1.0.0
1313
shared:
14-
path: ./shared
14+
path: ../shared
1515

1616
dev_dependencies:
1717
http: ^0.13.0

0 commit comments

Comments
 (0)