deploy on cloud
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -50,20 +50,20 @@ cp ./target/release/$APP_NAME /bin/server
|
|||||||
# By specifying the "3.18" tag, it will use version 3.18 of alpine. If
|
# By specifying the "3.18" tag, it will use version 3.18 of alpine. If
|
||||||
# reproducability is important, consider using a digest
|
# reproducability is important, consider using a digest
|
||||||
# (e.g., alpine@sha256:664888ac9cfd28068e062c991ebcff4b4c7307dc8dd4df9e728bedde5c449d91).
|
# (e.g., alpine@sha256:664888ac9cfd28068e062c991ebcff4b4c7307dc8dd4df9e728bedde5c449d91).
|
||||||
FROM scratch AS final
|
FROM alpine AS final
|
||||||
|
|
||||||
# Create a non-privileged user that the app will run under.
|
# Create a non-privileged user that the app will run under.
|
||||||
# See https://docs.docker.com/go/dockerfile-user-best-practices/
|
# See https://docs.docker.com/go/dockerfile-user-best-practices/
|
||||||
# ARG UID=10001
|
ARG UID=10001
|
||||||
# RUN adduser \
|
RUN adduser \
|
||||||
# --disabled-password \
|
--disabled-password \
|
||||||
# --gecos "" \
|
--gecos "" \
|
||||||
# --home "/nonexistent" \
|
--home "/nonexistent" \
|
||||||
# --shell "/sbin/nologin" \
|
--shell "/sbin/nologin" \
|
||||||
# --no-create-home \
|
--no-create-home \
|
||||||
# --uid "${UID}" \
|
--uid "${UID}" \
|
||||||
# appuser
|
appuser
|
||||||
# USER appuser
|
USER appuser
|
||||||
|
|
||||||
# Copy the executable from the "build" stage.
|
# Copy the executable from the "build" stage.
|
||||||
COPY --from=build /bin/server /bin/
|
COPY --from=build /bin/server /bin/
|
||||||
|
@@ -12,10 +12,8 @@ export class State {
|
|||||||
turn = $state(-1); // -1 not my turn, 0 might be, 1 is
|
turn = $state(-1); // -1 not my turn, 0 might be, 1 is
|
||||||
socket: Socket;
|
socket: Socket;
|
||||||
|
|
||||||
constructor(hostname: string) {
|
constructor() {
|
||||||
// let session = sessionStorage.getItem('session');
|
this.socket = io(`wss://battleship.icyground-d91964e0.centralindia.azurecontainerapps.io`, {
|
||||||
|
|
||||||
this.socket = io(`ws://${hostname}:3000/`, {
|
|
||||||
transports: ['websocket'],
|
transports: ['websocket'],
|
||||||
auth: { session: sessionStorage.getItem('session') }
|
auth: { session: sessionStorage.getItem('session') }
|
||||||
});
|
});
|
||||||
|
@@ -5,8 +5,7 @@
|
|||||||
import { State } from '$lib/state.svelte';
|
import { State } from '$lib/state.svelte';
|
||||||
import { Users } from 'lucide-svelte';
|
import { Users } from 'lucide-svelte';
|
||||||
|
|
||||||
const hostname = window.location.hostname;
|
let gameState = new State();
|
||||||
let gameState = new State(hostname);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="min-h-screen bg-base-300 py-8 px-4 sm:px-6 lg:px-8">
|
<div class="min-h-screen bg-base-300 py-8 px-4 sm:px-6 lg:px-8">
|
||||||
@@ -43,7 +42,7 @@
|
|||||||
class="btn btn-error text-xl"
|
class="btn btn-error text-xl"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
gameState.socket.emit('leave');
|
gameState.socket.emit('leave');
|
||||||
gameState = new State(window.location.hostname);
|
gameState = new State();
|
||||||
}}>Leave</button
|
}}>Leave</button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -27,7 +27,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.finish(),
|
.finish(),
|
||||||
)?;
|
)?;
|
||||||
let _ = dotenv();
|
let _ = dotenv();
|
||||||
let url = std::env::var("DATABASE_URL")?;
|
let url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||||
let pool = sqlx::postgres::PgPool::connect(&url).await?;
|
let pool = sqlx::postgres::PgPool::connect(&url).await?;
|
||||||
sqlx::migrate!("./migrations").run(&pool).await?;
|
sqlx::migrate!("./migrations").run(&pool).await?;
|
||||||
sqlx::query("DELETE FROM players").execute(&pool).await?;
|
sqlx::query("DELETE FROM players").execute(&pool).await?;
|
||||||
@@ -35,7 +35,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
io.ns("/", on_connect);
|
io.ns("/", on_connect);
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
// .route("/", post(game::create_board_route))
|
|
||||||
.layer(layer)
|
.layer(layer)
|
||||||
.layer(CorsLayer::very_permissive());
|
.layer(CorsLayer::very_permissive());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user