forked from Botanical/BotanJS
Update deployment
This commit is contained in:
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
resolver-go/dockerfiles/api.Dockerfile
|
||||||
@@ -18,6 +18,4 @@ run:
|
|||||||
- -exc
|
- -exc
|
||||||
- |
|
- |
|
||||||
VERSION=$( cat commit.sha )
|
VERSION=$( cat commit.sha )
|
||||||
cat k8s/configmap.yaml >> deploy-confs/prod.yaml
|
|
||||||
echo -e "\n---\n" >> deploy-confs/prod.yaml
|
|
||||||
sed "s/IMAGE_TAG/$VERSION/g" k8s/deployments.yaml >> deploy-confs/prod.yaml
|
sed "s/IMAGE_TAG/$VERSION/g" k8s/deployments.yaml >> deploy-confs/prod.yaml
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: astrojs-nginx-ctmpls
|
|
||||||
namespace: default
|
|
||||||
data:
|
|
||||||
default.conf.template: |
|
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
listen [::]:80;
|
|
||||||
server_name localhost;
|
|
||||||
|
|
||||||
expires 10d;
|
|
||||||
add_header Cache-Control "public";
|
|
||||||
|
|
||||||
location / {
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
index index.html index.htm;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+33
-56
@@ -22,56 +22,8 @@ spec:
|
|||||||
runAsNonRoot: true
|
runAsNonRoot: true
|
||||||
runAsUser: 1001
|
runAsUser: 1001
|
||||||
env:
|
env:
|
||||||
- name: DEBUG
|
- name: CLOSURE_ENDPOINT
|
||||||
value: "0"
|
value: "http://closure-api.default.svc.cluster.local/compile"
|
||||||
volumeMounts:
|
|
||||||
- name: cache
|
|
||||||
mountPath: "/app/cache"
|
|
||||||
livenessProbe:
|
|
||||||
exec:
|
|
||||||
command:
|
|
||||||
- sh
|
|
||||||
- -c
|
|
||||||
- wget -qO - http://127.0.0.1:5000/health
|
|
||||||
- name: redis
|
|
||||||
image: redis:6.0.8-alpine
|
|
||||||
- name: compiler
|
|
||||||
image: registry.k8s.astropenguin.net/closure-api:IMAGE_TAG
|
|
||||||
securityContext:
|
|
||||||
runAsNonRoot: true
|
|
||||||
env:
|
|
||||||
- name: DEBUG
|
|
||||||
value: "0"
|
|
||||||
volumeMounts:
|
|
||||||
- name: cache
|
|
||||||
mountPath: "/app/cache"
|
|
||||||
- name: assets
|
|
||||||
image: nginx:alpine
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: "/usr/share/nginx/html"
|
|
||||||
name: cache
|
|
||||||
- mountPath: "/etc/nginx/templates"
|
|
||||||
name: nginx-conf-templates
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: astrojs-cache
|
|
||||||
- name: nginx-conf-templates
|
|
||||||
configMap:
|
|
||||||
name: astrojs-nginx-ctmpls
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: astrojs-cache
|
|
||||||
spec:
|
|
||||||
accessModes: [ "ReadWriteOnce" ]
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 1Gi
|
|
||||||
storageClassName: local-storage
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -83,9 +35,34 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
app: astrojs
|
app: astrojs
|
||||||
ports:
|
ports:
|
||||||
- port: 5000
|
- port: 8080
|
||||||
targetPort: 5000
|
targetPort: 8080
|
||||||
name: application
|
name: web
|
||||||
- port: 80
|
|
||||||
targetPort: 80
|
---
|
||||||
name: files
|
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: HTTPRoute
|
||||||
|
metadata:
|
||||||
|
name: astrojs
|
||||||
|
spec:
|
||||||
|
parentRefs:
|
||||||
|
- name: gateway-prod
|
||||||
|
namespace: cilium-system
|
||||||
|
sectionName: k8s-astropenguin-net
|
||||||
|
hostnames:
|
||||||
|
- astrojs.k8s.astropenguin.net
|
||||||
|
rules:
|
||||||
|
- matches:
|
||||||
|
- path:
|
||||||
|
type: PathPrefix
|
||||||
|
value: /
|
||||||
|
filters:
|
||||||
|
- type: URLRewrite
|
||||||
|
urlRewrite:
|
||||||
|
path:
|
||||||
|
type: ReplaceFullPath
|
||||||
|
replaceFullPath: /
|
||||||
|
backendRefs:
|
||||||
|
- name: astrojs
|
||||||
|
port: 8080
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
name: default-astrojs
|
|
||||||
namespace: ingress-https
|
|
||||||
spec:
|
|
||||||
ingressClassName: nginx
|
|
||||||
tls:
|
|
||||||
- hosts:
|
|
||||||
- astrojs.k8s.astropenguin.net
|
|
||||||
secretName: any-k8s-astro-prod
|
|
||||||
rules:
|
|
||||||
- host: astrojs.k8s.astropenguin.net
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- path: /
|
|
||||||
pathType: Prefix
|
|
||||||
backend:
|
|
||||||
service:
|
|
||||||
name: default-astrojs
|
|
||||||
port:
|
|
||||||
number: 5000
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
kind: Service
|
|
||||||
apiVersion: v1
|
|
||||||
metadata:
|
|
||||||
name: default-astrojs
|
|
||||||
namespace: ingress-https
|
|
||||||
spec:
|
|
||||||
type: ExternalName
|
|
||||||
externalName: astrojs.default.svc.cluster.local
|
|
||||||
@@ -34,6 +34,12 @@ push-resolver: .buildinfo ensure-buildx resolver-gen
|
|||||||
-t $(RESOLVER_IMAGE_NAME):$(RESOLVER_IMAGE_TAG) \
|
-t $(RESOLVER_IMAGE_NAME):$(RESOLVER_IMAGE_TAG) \
|
||||||
--push .
|
--push .
|
||||||
|
|
||||||
|
run-api-server:
|
||||||
|
cd $(GO_SRC_DIR) && \
|
||||||
|
go run ./cmd/classmap-gen -src "$(JS_SRC_DIR)" && \
|
||||||
|
go run ./cmd/externs-gen -src "$(JS_SRC_DIR)" && \
|
||||||
|
go run ./cmd/api-server -src "$(JS_SRC_DIR)" -addr :8080
|
||||||
|
|
||||||
inspect-resolver:
|
inspect-resolver:
|
||||||
docker buildx imagetools inspect $(RESOLVER_IMAGE_NAME):$(RESOLVER_IMAGE_TAG)
|
docker buildx imagetools inspect $(RESOLVER_IMAGE_NAME):$(RESOLVER_IMAGE_TAG)
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,7 @@ Go rewrite for the old BotanJS dynamic resource resolver.
|
|||||||
## Generate the class map
|
## Generate the class map
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go run ./cmd/botan-gen \
|
make resolver-gen
|
||||||
-src /path/to/BotanJS/src \
|
|
||||||
-out internal/generated/classmap_gen.go
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Commit the generated file if the source tree is mostly static. Generate it in CI if the source changes frequently.
|
Commit the generated file if the source tree is mostly static. Generate it in CI if the source changes frequently.
|
||||||
@@ -20,7 +18,7 @@ Commit the generated file if the source tree is mostly static. Generate it in CI
|
|||||||
## Run API
|
## Run API
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go run ./cmd/botan-api -src /path/to/BotanJS/src -addr :8080
|
make run-api-server
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
@@ -43,6 +41,4 @@ Prefix an item with `-` to exclude it.
|
|||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- Test against the old python resolver output
|
- Fix moderen closure errors
|
||||||
- Add an output interface so JS can be piped directly to a Closure Compiler server.
|
|
||||||
- Put generated classmap in a separate package if multiple services need to import it.
|
|
||||||
|
|||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../botanjs/
|
||||||
@@ -19,15 +19,15 @@ RUN --mount=type=cache,target=/go/pkg/mod \
|
|||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GOOS=$TARGETOS \
|
GOOS=$TARGETOS \
|
||||||
GOARCH=$TARGETARCH \
|
GOARCH=$TARGETARCH \
|
||||||
go build -trimpath -o /out/botan-api -ldflags='-s -w' ./cmd/botan-api
|
go build -trimpath -o /out/api-server -ldflags='-s -w' ./cmd/api-server
|
||||||
|
|
||||||
RUN mkdir -p /out/tmp && chmod 1777 /out/tmp
|
RUN mkdir -p /out/tmp && chmod 1777 /out/tmp
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
COPY --from=build /out/botan-api /usr/local/bin/botan-api
|
COPY --from=build /out/api-server /usr/local/bin/api-server
|
||||||
COPY --from=build /workspace/src "./src"
|
COPY --from=build /workspace/src "./src"
|
||||||
COPY --from=build /out/tmp /tmp
|
COPY --from=build /out/tmp /tmp
|
||||||
|
|
||||||
EXPOSE 8080/tcp
|
EXPOSE 8080/tcp
|
||||||
ENTRYPOINT ["/usr/local/bin/botan-api", "-src", "./src", "-addr", ":8080"]
|
ENTRYPOINT ["/usr/local/bin/api-server", "-src", "./src", "-addr", ":8080"]
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ package generated
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
IMAGE_TAG = "dev"
|
IMAGE_TAG = "dev"
|
||||||
Timestamp = "20260612.043857"
|
Timestamp = "20260612.044857"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../botanjs/src
|
|
||||||
Reference in New Issue
Block a user