Browse Source

Move server, bind www folder

pull/926/head
Daniil Isakov 3 years ago
parent
commit
6d1e8310f2
  1. 6
      Dockerfile
  2. 3
      docker-compose.dev.yml
  3. 2
      src/lib/Server.js
  4. 1
      webui/package.json

6
Dockerfile

@ -19,7 +19,7 @@ RUN npm ci --omit=dev
FROM docker.io/library/node:18-alpine FROM docker.io/library/node:18-alpine
# Copy the server files and the built static files # Copy the server files and the built static files
COPY --from=build_node_modules /server /app COPY --from=build_node_modules /server /app/server
COPY --from=build_node_modules /webui/dist /app/www COPY --from=build_node_modules /webui/dist /app/www
# Move node_modules one directory up, so during development # Move node_modules one directory up, so during development
@ -29,7 +29,7 @@ COPY --from=build_node_modules /webui/dist /app/www
# Also, some node_modules might be native, and # Also, some node_modules might be native, and
# the architecture & OS of your development machine might differ # the architecture & OS of your development machine might differ
# than what runs inside of docker. # than what runs inside of docker.
RUN mv /app/node_modules /node_modules RUN mv /app/server/node_modules /app/node_modules
# Enable this to run `npm run serve` # Enable this to run `npm run serve`
RUN npm i -g nodemon RUN npm i -g nodemon
@ -53,5 +53,5 @@ EXPOSE 51821/tcp
ENV DEBUG=Server,WireGuard ENV DEBUG=Server,WireGuard
# Run Web UI # Run Web UI
WORKDIR /app WORKDIR /app/server
CMD ["/usr/bin/dumb-init", "node", "server.js"] CMD ["/usr/bin/dumb-init", "node", "server.js"]

3
docker-compose.dev.yml

@ -4,7 +4,8 @@ services:
image: wg-easy image: wg-easy
command: npm run serve command: npm run serve
volumes: volumes:
- ./src/:/app/ - ./src/:/app/server
- ./webui/dist:/app/www
environment: environment:
# - PASSWORD=p # - PASSWORD=p
- WG_HOST=192.168.1.233 - WG_HOST=192.168.1.233

2
src/lib/Server.js

@ -25,7 +25,7 @@ module.exports = class Server {
// Express // Express
this.app = express() this.app = express()
.disable('etag') .disable('etag')
.use('/', express.static(path.join(__dirname, '..', 'www'))) .use('/', express.static(path.join(__dirname, '..', '..', 'www')))
.use(express.json()) .use(express.json())
.use(expressSession({ .use(expressSession({
secret: crypto.randomBytes(256).toString('hex'), secret: crypto.randomBytes(256).toString('hex'),

1
webui/package.json

@ -6,6 +6,7 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"build:watch": "vite build --watch",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {

Loading…
Cancel
Save