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
|
||||
- |
|
||||
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
|
||||
|
||||
@@ -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
|
||||
runAsUser: 1001
|
||||
env:
|
||||
- name: DEBUG
|
||||
value: "0"
|
||||
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
|
||||
- name: CLOSURE_ENDPOINT
|
||||
value: "http://closure-api.default.svc.cluster.local/compile"
|
||||
|
||||
---
|
||||
|
||||
@@ -83,9 +35,34 @@ spec:
|
||||
selector:
|
||||
app: astrojs
|
||||
ports:
|
||||
- port: 5000
|
||||
targetPort: 5000
|
||||
name: application
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
name: files
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
name: web
|
||||
|
||||
---
|
||||
|
||||
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) \
|
||||
--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:
|
||||
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
|
||||
|
||||
```sh
|
||||
go run ./cmd/botan-gen \
|
||||
-src /path/to/BotanJS/src \
|
||||
-out internal/generated/classmap_gen.go
|
||||
make resolver-gen
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
```sh
|
||||
go run ./cmd/botan-api -src /path/to/BotanJS/src -addr :8080
|
||||
make run-api-server
|
||||
```
|
||||
|
||||
Examples:
|
||||
@@ -43,6 +41,4 @@ Prefix an item with `-` to exclude it.
|
||||
|
||||
## TODO
|
||||
|
||||
- Test against the old python resolver output
|
||||
- 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.
|
||||
- Fix moderen closure errors
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../botanjs/
|
||||
@@ -19,15 +19,15 @@ RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
CGO_ENABLED=0 \
|
||||
GOOS=$TARGETOS \
|
||||
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
|
||||
|
||||
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 /out/tmp /tmp
|
||||
|
||||
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 (
|
||||
IMAGE_TAG = "dev"
|
||||
Timestamp = "20260612.043857"
|
||||
Timestamp = "20260612.044857"
|
||||
)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../botanjs/src
|
||||
Reference in New Issue
Block a user