Skip to content

Commit

Permalink
web: add local mode and use that in Dockerfile.local
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Oct 24, 2024
1 parent 3f6475d commit ebcc988
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ RUN /opt/racket/bin/raco pkg install --auto congame-core/ congame-web/ conscript
RUN npm install
RUN npm run-script build

CMD ["dumb-init", "/opt/racket/bin/racket", "congame-web/dynamic.rkt"]
CMD ["dumb-init", "/opt/racket/bin/racket", "congame-web/dynamic.rkt", "--mode", "local"]
13 changes: 13 additions & 0 deletions congame-web/dynamic.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,20 @@
(get-registered-studies))

(module+ main
(require racket/cmdline
racket/lazy-require)
(lazy-require
("local.rkt" [(setup local:setup)]))
(define mode 'standard)
(command-line
#:once-each
[("--mode" "-m")
MODE "the mode the server is run in"
(set! mode (string->symbol MODE))])
(define stop (start))
(case mode
[(local) (local:setup)]
[else (void)])
(with-handlers ([exn:break? void])
(sync/enable-break never-evt))
(stop))
25 changes: 25 additions & 0 deletions congame-web/local.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#lang racket/base

#| This module sets up an admin account on first run for a
docker-compose-based local setup. Relies on the fact that (start)
sets (current-system) to prod-system. |#

(require component
"components/user.rkt")

(provide
setup)

(define (setup)
(with-handlers ([exn:fail:user-manager:username-taken? void])
(define users (system-ref 'users))
(define the-user
(user-manager-create!
users
"[email protected]"
"admin"
#(admin)))
(user-manager-verify!
users
(user-id the-user)
(user-verification-code the-user))))

0 comments on commit ebcc988

Please sign in to comment.