From 74b638887dfb974bf457e65d4e1de1fb9d1b0a8d Mon Sep 17 00:00:00 2001 From: Dany Sluijk Date: Tue, 26 Jul 2022 20:41:26 +0200 Subject: [PATCH] fix(docker): fix watching of app, and re-add it to compose --- README.md | 14 ++++++-------- docker-compose.yml | 19 +++++++++++++++++++ nuxt.config.ts | 13 ++++++++++++- package.json | 11 ++++++----- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 2731b3e..293b0a1 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,19 @@ This website is still under construction. This is not in use yet :(. ## Development -To run the application in development, you will have to have an recent version of Node installed (16 or 18). -Additional services are run in Docker, but a compose file is provided. -First you will have to start with with Docker Compose: +Development is done with Docker, with the settings provided. +To run all needed components, a compose file is provided. +Note: the force recreate option is required as there is currently a [known issue](https://github.com/nuxt/framework/issues/3998) with Nuxt in Docker. +This can be run with: ```bash -docker-compose up -d +docker-compose up --force-recreate ``` This exposes several services: +- The application itself at [localhost:3000](http://localhost:3000). - The Postgres database to connect to, accesible at the default port `5432`. - An Adminer instance, to explore the database, accesible at [localhost:8080](http://localhost:8080). - Mailcatcher SMTP server, at port 1025. - Mailcatcher to view the outgoing email at [localhost:8081](http://localhost:8081). - -To then start the server itself, you need to install the dependencies first using `yarn install`. -When this is done you can start the dev server with `yarn dev`. -Now you can view the server at [localhost:3000](http://localhost:3000). diff --git a/docker-compose.yml b/docker-compose.yml index ea87b59..0263545 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,25 @@ version: "3" services: + server: + image: node:18.6 + working_dir: /lan + command: ["sh", "-c", "yarn install && yarn dev"] + container_name: lan-server + restart: unless-stopped + ports: + - 3000:3000 + - 24678:24678 # HMR Port + environment: + HOST: "0.0.0.0" + env_file: + - .env + - .env.local + depends_on: + - database + - mailcatcher + volumes: + - ./:/lan database: container_name: lan-database image: "postgres:latest" diff --git a/nuxt.config.ts b/nuxt.config.ts index 61961c2..7aa5297 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,4 +1,15 @@ import { defineNuxtConfig } from "nuxt"; // https://v3.nuxtjs.org/api/configuration/nuxt.config -export default defineNuxtConfig({}); +export default defineNuxtConfig({ + typescript: { + strict: true, + }, + vite: { + server: { + hmr: { + protocol: "ws", + }, + }, + }, +}); diff --git a/package.json b/package.json index fbb7523..b081742 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,13 @@ "author": "LANDev ", "private": true, "scripts": { - "build": "nuxt build", - "dev": "nuxt dev", - "generate": "nuxt generate", - "preview": "nuxt preview" + "dev": "nuxt dev --no-clear", + "build": "nuxt build --prerender", + "serve": "yarn build && nuxt preview", + "typecheck": "nuxt typecheck" }, "devDependencies": { - "nuxt": "3.0.0-rc.6" + "nuxt": "3.0.0-rc.6", + "serve": "^14.0.1" } }