Prepare for deployment

This commit is contained in:
nemunaire 2022-03-01 13:46:44 +01:00
parent f85758ef33
commit d440d85dc1
7 changed files with 79 additions and 9 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
ui/node_modules
ui/build

View File

@ -8,6 +8,16 @@ platform:
arch: arm
steps:
- name: build front
image: node:17-alpine
commands:
- mkdir deploy
- apk --no-cache add python2 build-base
- cd ui
- npm install --network-timeout=100000
- npm run build
- tar chjf ../deploy/static.tar.bz2 build
- name: vet
image: golang:alpine
commands:
@ -44,6 +54,16 @@ platform:
arch: arm64
steps:
- name: build front
image: node:17-alpine
commands:
- mkdir deploy
- apk --no-cache add python2 build-base
- cd ui
- npm install --network-timeout=100000
- npm run build
- tar chjf ../deploy/static.tar.bz2 build
- name: vet
image: golang:alpine
commands:

View File

@ -1,18 +1,30 @@
FROM golang:alpine as gobuild
FROM node:17-alpine as nodebuild
WORKDIR /ui
RUN apk --no-cache add python2 build-base
COPY ui/ .
RUN npm install --network-timeout=100000 && \
npm run build
FROM golang:1-alpine as gobuild
RUN apk add --no-cache go-bindata
WORKDIR /go/src/git.nemunai.re/atsebay.t
COPY *.go go.mod go.sum ./
COPY htdocs/ ./htdocs/
COPY --from=nodebuild /ui/build ui/build
RUN go generate -v && \
go get -d -v && \
go build -v -ldflags="-s -w"
RUN go get -d -v && \
go generate -v && \
go build -v -ldflags="-s -w" -o atsebay.t
FROM alpine
FROM alpine:3.15
EXPOSE 8081

View File

@ -10,15 +10,15 @@ import (
"net/http"
)
//go:embed htdocs
//go:embed ui/build/* ui/build/_app/* ui/build/_app/assets/pages/* ui/build/_app/pages/* ui/build/_app/pages/grades/* ui/build/_app/pages/surveys/* ui/build/_app/pages/surveys/_sid_/* ui/build/_app/pages/surveys/_sid_/responses/* ui/build/_app/pages/users/* ui/build/_app/pages/users/_uid_/* ui/build/_app/pages/users/_uid_/surveys/*
var _assets embed.FS
var Assets http.FileSystem
func init() {
sub, err := fs.Sub(_assets, "htdocs")
sub, err := fs.Sub(_assets, "ui/build")
if err != nil {
log.Fatal("Unable to cd to htdocs/ directory:", err)
log.Fatal("Unable to cd to ui/build/ directory:", err)
}
Assets = http.FS(sub)
}

31
ui/package-lock.json generated
View File

@ -127,6 +127,15 @@
"picomatch": "^2.2.2"
}
},
"@sveltejs/adapter-static": {
"version": "1.0.0-next.28",
"resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-1.0.0-next.28.tgz",
"integrity": "sha512-c4xLyeSwnbGQxe4f1SLpHTbxZDm3TEr43scR3tOlVgQN+mnAL9aDdl3nTtdzWmrUDmDEmY4GriAwLyFLZuINLw==",
"dev": true,
"requires": {
"tiny-glob": "^0.2.9"
}
},
"@sveltejs/kit": {
"version": "1.0.0-next.266",
"resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.0.0-next.266.tgz",
@ -1034,6 +1043,12 @@
"type-fest": "^0.20.2"
}
},
"globalyzer": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
"integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==",
"dev": true
},
"globby": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
@ -1048,6 +1063,12 @@
"slash": "^3.0.0"
}
},
"globrex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==",
"dev": true
},
"graceful-fs": {
"version": "4.2.9",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz",
@ -1768,6 +1789,16 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"tiny-glob": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
"integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
"dev": true,
"requires": {
"globalyzer": "0.1.0",
"globrex": "^0.1.2"
}
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",

View File

@ -11,6 +11,7 @@
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"devDependencies": {
"@sveltejs/adapter-static": "^1.0.0-next.28",
"@sveltejs/kit": "^1.0.0-next.266",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",

View File

@ -1,3 +1,4 @@
import adapter from '@sveltejs/adapter-static';
import preprocess from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */
@ -7,6 +8,9 @@ const config = {
preprocess: preprocess(),
kit: {
adapter: adapter({
fallback: 'index.html'
}),
}
};