Skip to content

Commit

Permalink
setup docker workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Oct 3, 2023
1 parent 5f45308 commit c6c3db7
Show file tree
Hide file tree
Showing 18 changed files with 254 additions and 116 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
jame: Build
on:
push:
branches:
Expand Down Expand Up @@ -33,7 +33,8 @@ jobs:
- uses: actions/upload-artifact@v3
with:
path: web-client/dist
name: app-${{ github.sha }}
name: app
retention-days: 3

build-docs:
name: Build Docs
Expand All @@ -58,7 +59,8 @@ jobs:
- uses: actions/upload-artifact@v3
with:
path: docs/src/.vitepress/dist
name: docs-${{ github.sha }}
name: docs
retention-days: 3

build-server:
name: Build Server
Expand All @@ -84,5 +86,6 @@ jobs:
- uses: actions/upload-artifact@v3
with:
path: target/x86_64-unknown-linux-musl/release/celerserver
name: celerserver-${{ github.sha }}
name: celerserver
retention-days: 3

32 changes: 32 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Docker
on:
workflow_dispatch:
inputs:
version:
description: "Version tag of the image (e.g. 0.2.0-beta)"
required: true
pull_request:
branches:
- main

jobs:
build-docker:
name: WIP Publish Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build.yml
commit: a5dda8f40b034167ba31995f9a865dd2dfb1c138 #${{ github.sha }}
path: docker/dist
- uses: actions/upload-artifact@v3
with:
path: docker
name: docker
retention-days: 1
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions Dockerfile

This file was deleted.

32 changes: 4 additions & 28 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ includes:
aliases: [themes, th]
dir: ./web-themes

docker:
taskfile: ./docker
dir: ./docker

tasks:
install:
desc: Install development dependencies and packages
Expand Down Expand Up @@ -67,34 +71,6 @@ tasks:
cmds:
- cargo fmt

docker:
deps: [build]
desc: Build docker container
cmds:
- task: docker:build

docker:build:
cmds:
- docker build -t pistonite/celer . --no-cache

docker:run:
desc: Run docker container
cmds:
- docker run -p 8000:80 pistonite/celer

docker:stop:
desc: Stop docker container
cmds:
- docker stop $(docker ps -q -a --filter ancestor=pistonite/celer)

docker:push:
desc: Push the container to docker hub. Takes in the tag [defaults to latest]
interactive: true
cmds:
- docker login
- docker push pistonite/celer:{{.CLI_ARGS | default "latest" }}
- docker logout

build:
desc: Build production assets
deps:
Expand Down
9 changes: 9 additions & 0 deletions compiler-core/src/util/site_origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@ pub fn get_site_origin() -> &'static str {
None => "",
}
}

/// Get the site domain (origin without url scheme)
pub fn get_site_domain() -> &'static str {
let origin = get_site_origin();
match origin.strip_prefix("https://") {
Some(domain) => domain,
None => origin.strip_prefix("http://").unwrap_or(origin),
}
}
11 changes: 0 additions & 11 deletions docker/Cargo.toml

This file was deleted.

15 changes: 15 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:latest
EXPOSE 80
ENV APP_DIR=/opt/app
COPY ./dist $APP_DIR

WORKDIR $APP_DIR

ENV CELERSERVER_LOG=INFO \
CELERSERVER_ANSI=false \
CELERSERVER_PORT=80 \
CELERSERVER_DOCS_DIR=/opt/app/docs \
CELERSERVER_APP_DIR=/opt/app/app \
CELERSERVER_GZIP=true

CMD ["./celerserver"]
22 changes: 22 additions & 0 deletions docker/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,25 @@ tasks:
- cp -r ../docs/src/.vitepress/dist/* dist/docs
- cp -r ../web-client/dist/* dist/app
- cp ../target/x86_64-unknown-linux-musl/release/celerserver dist

build:
desc: Build docker container locally (requires building assets first)
deps: [pull]
cmds:
- task: build-container
vars:
ARGS: --no-cache

build-container:
cmds:
- docker build -t ghcr.io/pistonite/celer . {{.ARGS}}

run:
desc: Run docker container
cmds:
- docker run -p 8000:80 ghcr.io/pistonite/celer -e CELERSERVER_SITE_ORIGIN=http://pistonite.local

stop:
desc: Stop docker container
cmds:
- docker stop $(docker ps -q -a --filter ancestor=ghcr.io/pistonite/celer)
4 changes: 0 additions & 4 deletions docker/src/build.rs

This file was deleted.

1 change: 0 additions & 1 deletion docs/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ tasks:
deps: [txtpp]
cmds:
- npx vitepress build src > /dev/null 2> /dev/null
# - gzip src/.vitepress/dist/*.html src/.vitepress/dist/**/*.html src/.vitepress/dist/**/*.js src/.vitepress/dist/**/*.css -r -k -v

check:
desc: Check for issues in the docs
Expand Down
1 change: 0 additions & 1 deletion web-client/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ tasks:
- npx vite build
- node tools/post-build.cjs
- rm dist/index.html
# - gzip dist/*.html dist/**/*.js dist/**/*.css dist/**/*.wasm -k -v

check:
desc: Check for linting and formatting issues in web client
Expand Down
1 change: 1 addition & 0 deletions web-client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
content="Create your route with the web editor"
/>
<!-- EDITOR -->
<script>window.__CELER_VERSION="0.0.0-dev unknown"</script>
</head>
<body>
<div id="react-root">
Expand Down
2 changes: 2 additions & 0 deletions web-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ tower = "0.4.13"
tower-http = { version = "0.4.4", features = ["fs", "trace"] }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["ansi"] }
flate2 = "1.0.27"
once_cell = "1.18.0"

[[bin]]
name = "celerserver"
Expand Down
1 change: 1 addition & 0 deletions web-server/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ tasks:
CELERSERVER_HTTPS_CERT: ../cert/cert.pem
CELERSERVER_HTTPS_KEY: ../cert/cert-key.pem
CELERSERVER_SITE_ORIGIN: https://pistonite.local
CELERSERVER_GZIP: "true"
cmds:
- cargo watch -B 1 -s "cargo run --bin celerserver -- {{.CLI_ARGS}}"
Loading

0 comments on commit c6c3db7

Please sign in to comment.