Skip to content

Commit

Permalink
chore: fix deploy docker ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgehermo9 committed Jan 23, 2025
1 parent 0897e27 commit f54a7b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/loco-gen-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
env:
RUST_TOOLCHAIN: stable
TOOLCHAIN_PROFILE: minimal
LOCO_DEV_MODE_PATH: ${{ github.workspace }}

jobs:
g-deploy-docker:
Expand Down Expand Up @@ -37,13 +38,15 @@ jobs:
run: |
loco new -n myapp --db sqlite --bg async --assets serverside -a
working-directory: /tmp
env:
LOCO_DEV_MODE_PATH: loco

- name: generate deployment
run: cargo loco generate deployment --kind docker
working-directory: /tmp/myapp

- name: copy local loco dependency
run: |
cp -r ${{github.workspace}} /tmp/myapp/loco
- name: generate deployment
run: cargo loco generate deployment --kind docker && docker build -t demo .
- name: build deployment
run: docker build -t demo .
working-directory: /tmp/myapp
4 changes: 3 additions & 1 deletion loco-gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,12 @@ pub fn generate(rrgen: &RRgen, component: Component, appinfo: &AppInfo) -> Resul
port,
} => match kind {
DeploymentKind::Docker => {
let loco_dev_mode_path = std::env::var("LOCO_DEV_MODE_PATH");
let vars = json!({
"pkg_name": appinfo.app_name,
"copy_asset_folder": asset_folder.unwrap_or_default(),
"fallback_file": fallback_file.unwrap_or_default()
"fallback_file": fallback_file.unwrap_or_default(),
"loco_dev_mode_path": loco_dev_mode_path.unwrap_or_default()
});
render_template(rrgen, Path::new("deployment/docker"), &vars)?
}
Expand Down
5 changes: 4 additions & 1 deletion loco-gen/src/templates/deployment/docker/docker.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ FROM rust:1.83.0-slim as builder
WORKDIR /usr/src/

COPY . .

{% if loco_dev_mode_path -%}
# The `loco` root folder should be moved to this dockerfile path so the context can copy it to the image
RUN mkdir -p {{loco_dev_mode_path}} && mv loco/* {{loco_dev_mode_path}}
{% endif -%}
RUN cargo build --release

FROM debian:bookworm-slim
Expand Down

0 comments on commit f54a7b0

Please sign in to comment.