Skip to content

Commit

Permalink
update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
necessarylion committed Jul 18, 2023
1 parent 398f028 commit a6bc371
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@ COPY . .
RUN dart run build_runner build --delete-conflicting-outputs
RUN dart compile exe bin/server.dart -o bin/server

# Build minimal serving image from AOT-compiled `/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/.env /
COPY --from=build /app/bin/server /bin/
COPY --from=build /app/db/migration /db/migration

# Start server.
CMD ["/bin/server"]
3 changes: 3 additions & 0 deletions bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ void main() async {

/// Initialize Postgres connection
Database().setup(config);

/// run migration
await Database().migrate();
}
24 changes: 17 additions & 7 deletions lib/config/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import 'package:postgres_pool/postgres_pool.dart';

class Database {
late PgPool pool;
late PgEndpoint endPoint;

void setup(AppConfig appConfig) {
DBConfig config = appConfig.dbConfig;

endPoint = PgEndpoint(
host: config.dbHost,
port: config.dbPort,
database: config.dbName,
username: config.dbUsername,
password: config.dbPassword,
);

pool = PgPool(
PgEndpoint(
host: config.dbHost,
port: config.dbPort,
database: config.dbName,
username: config.dbUsername,
password: config.dbPassword,
),
endPoint,
settings: PgPoolSettings()
..maxConnectionAge = Duration(hours: 1)
..concurrency = 4,
Expand All @@ -24,9 +28,15 @@ class Database {
SqlQueryBuilder.initialize(
database: pool,
debug: config.enableQueryLog,
printer: ConsoleQueryPrinter(),
);
}

Future<void> migrate() async {
// uncomment below line to run migration on application startup
// await Migration().migrate();
}

/// Declare as Singleton
static final Database _i = Database._internal();
factory Database() => _i;
Expand Down
16 changes: 12 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,26 @@ packages:
dependency: "direct main"
description:
name: dox_core
sha256: "98434c0c76dcfa20ff3e0a52d7dae942f966aaab84617d3ae495dbcc7a72ca82"
sha256: "8cdb8e310205be8e95a2304912cabf0003e4dcabc6a940a978db06a33a495021"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.0.5"
dox_migration:
dependency: "direct main"
description:
name: dox_migration
sha256: b925dfc4051e6fc71e086c2a3f53eeae11f4f8b387be55a8094e0fadb997b47f
url: "https://pub.dev"
source: hosted
version: "1.0.3"
dox_query_builder:
dependency: "direct main"
description:
name: dox_query_builder
sha256: f60f6469abb06316420093f62413d77d42b694849f0c7d5fb76b3697ce015dde
sha256: dfa2287749d7d328e624165369c6af16eefb7c29782401244f75731fa5db200e
url: "https://pub.dev"
source: hosted
version: "1.1.11"
version: "1.1.13"
encrypt:
dependency: transitive
description:
Expand Down
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ environment:
sdk: '>=2.19.0 <4.0.0'

dependencies:
dox_core: ^1.0.2
dox_core: ^1.0.5
postgres_pool: ^2.1.6
dox_query_builder: ^1.1.11
dox_query_builder: ^1.1.13
dox_migration: ^1.0.3

dev_dependencies:
dox_builder: ^1.0.1
Expand Down

0 comments on commit a6bc371

Please sign in to comment.