mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-07-29 17:02:56 -04:00
add docker build
This commit is contained in:
12
.dockerignore
Normal file
12
.dockerignore
Normal file
@@ -0,0 +1,12 @@
|
||||
.git
|
||||
.gitignore
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
README.md
|
||||
|
||||
frontend/.svelte-kit
|
||||
frontend/node_modules
|
||||
frontend/build
|
||||
|
||||
backend/pb_data
|
||||
backend/pb_public
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -192,10 +192,7 @@ package
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/go,visualstudiocode,svelte,node
|
||||
|
||||
frontend/build
|
||||
frontend/.svelte-kit
|
||||
frontend/vite.config.js.timestamp-*
|
||||
frontend/vite.config.ts.timestamp-*
|
||||
build
|
||||
|
||||
backend/pb_data
|
||||
backend/pb_public/*
|
||||
|
||||
22
Dockerfile
Normal file
22
Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
||||
FROM node:19-alpine as frontend
|
||||
COPY frontend /app
|
||||
WORKDIR /app
|
||||
RUN npm i &&\
|
||||
npm run build
|
||||
|
||||
FROM golang:1.19-alpine as backend
|
||||
COPY backend /app
|
||||
WORKDIR /app
|
||||
COPY --from=frontend /app/build pb_public
|
||||
RUN apk update &&\
|
||||
apk add gcc musl-dev &&\
|
||||
go mod tidy &&\
|
||||
go build -ldflags "-s -w" -o upsnap main.go
|
||||
|
||||
FROM alpine:3.17
|
||||
WORKDIR /app
|
||||
COPY --from=backend /app/upsnap .
|
||||
RUN apk update &&\
|
||||
apk add --no-cache nmap curl samba-common-tools &&\
|
||||
rm -rf /var/cache/apk/*
|
||||
CMD ["./upsnap", "serve", "--http", "0.0.0.0:8090"]
|
||||
@@ -1,9 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/seriousm4x/upsnap/backend/pb"
|
||||
)
|
||||
|
||||
//go:embed all:pb_public
|
||||
var distDir embed.FS
|
||||
var distDirFS = echo.MustSubFS(distDir, "pb_public")
|
||||
|
||||
func main() {
|
||||
pb.StartPocketBase()
|
||||
pb.StartPocketBase(distDirFS)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package pb
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -18,7 +19,7 @@ import (
|
||||
|
||||
var App *pocketbase.PocketBase
|
||||
|
||||
func StartPocketBase() {
|
||||
func StartPocketBase(distDirFS fs.FS) {
|
||||
App = pocketbase.New()
|
||||
App.RootCmd.Short = "UpSnap CLI"
|
||||
App.RootCmd.Version = "3.0.0b1"
|
||||
@@ -31,7 +32,7 @@ func StartPocketBase() {
|
||||
// event hooks
|
||||
App.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
||||
// set static website path
|
||||
e.Router.GET("/*", apis.StaticDirectoryHandler(os.DirFS("./pb_public"), true))
|
||||
e.Router.GET("/*", apis.StaticDirectoryHandler(distDirFS, true))
|
||||
|
||||
// add wake route to api
|
||||
e.Router.AddRoute(echo.Route{
|
||||
|
||||
11
docker-compose.yml
Normal file
11
docker-compose.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
version: "3"
|
||||
services:
|
||||
upsnap:
|
||||
build: .
|
||||
network_mode: host
|
||||
command: ["./upsnap", "serve", "--http", "0.0.0.0:8090"]
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-fs", "http://localhost:8090/api/health"]
|
||||
interval: 1m
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
@@ -341,7 +341,10 @@
|
||||
<div class="callout callout-info mb-auto">
|
||||
<h5>Optional:</h5>
|
||||
<p class="m-0">(1) Same cron syntax as for ping interval.</p>
|
||||
<p class="m-0">(2) Shell command to be executed. e.g.:</p>
|
||||
<p class="m-0">
|
||||
(2) Shell command to be executed. "net rpc", "sshpass" and "nmap" are available.
|
||||
e.g.:
|
||||
</p>
|
||||
<ul>
|
||||
<li>Windows: "net rpc shutdown -I 192.168.1.13 -U test%test"</li>
|
||||
<li>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export const prerender = true;
|
||||
export const trailingSlash = 'always';
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
export const prerender = true;
|
||||
|
||||
/** @type {import('./$types').PageLoad} */
|
||||
export function load({ params }) {
|
||||
return { params };
|
||||
|
||||
@@ -9,7 +9,9 @@ const config = {
|
||||
preprocess: preprocess(),
|
||||
|
||||
kit: {
|
||||
adapter: adapter(),
|
||||
adapter: adapter({
|
||||
fallback: 'index.html'
|
||||
}),
|
||||
alias: {
|
||||
'@components': path.resolve('./src/components'),
|
||||
'@stores': path.resolve('./src/stores')
|
||||
|
||||
Reference in New Issue
Block a user