mattwparas / steel

An embedded scheme interpreter in Rust
Apache License 2.0
1.07k stars 50 forks source link

Issues building steel inside docker #117

Closed kskarthik closed 9 months ago

kskarthik commented 9 months ago

Using rust:slim as base img

At the following Dockerfile steps:

RUN mkdir -p /lib/steel && \
export STEEL_HOME="/lib/steel"

RUN cargo build

RUN target/debug/steel cogs/install.scm

I get this below err:

error[E11]: Generic
   ┌─ cogs/install.scm:11:1
   │
11 │ 
   │   Error: Generic: environment variable not found

Error: SteelErr { repr: Repr { kind: Generic, message: "Error: Generic: environment v
ariable not found", span: Some(1085..1092), stack_trace: Some(DehydratedStackTrace { 
stack_trace: [] }) } }
The command '/bin/sh -c ls target/** && target/debug/steel cogs/install.scm' returned
 a non-zero code: 1

Did i miss setting any ENV ?

mattwparas commented 9 months ago

Maybe try setting STEEL_HOME with the ENV line? Like so:

ENV STEEL_HOME="/lib/steel"
kskarthik commented 9 months ago

Well, It didn't help as well, Here's my Dockerfile

# FROM rust:alpine as build
FROM rust:slim as build

COPY . /steel/

WORKDIR /steel

RUN apt update && \
        apt install -y \
        build-essential \
        libssl-dev \
        openssl \
        pkg-config

# RUN apk update && \
#       apk add openssl-dev \
#       openssl \
#       pkgconfig \
#       alpine-sdk

RUN mkdir -p /lib/steel/

ENV STEEL_HOME="/lib/steel"

RUN cargo build

RUN cargo run -- cogs/install.scm
mattwparas commented 9 months ago

I managed to build it using that Dockerfile - here is the output:

➜  steel git:(mwp-improper-lists) ✗ docker build .     
[+] Building 63.8s (12/12) FINISHED                                               docker:default
 => [internal] load build definition from Dockerfile                                        0.0s
 => => transferring dockerfile: 424B                                                        0.0s
 => [internal] load .dockerignore                                                           0.0s
 => => transferring context: 48B                                                            0.0s
 => [internal] load metadata for docker.io/library/rust:slim                                0.3s
 => [internal] load build context                                                           1.2s
 => => transferring context: 204.43MB                                                       1.1s
 => CACHED [1/7] FROM docker.io/library/rust:slim@sha256:8f7df8eb8f5fc25284cb83a0ba6088a09  0.0s
 => [2/7] COPY . /steel/                                                                    1.0s
 => [3/7] WORKDIR /steel                                                                    0.0s
 => [4/7] RUN apt update &&   apt install -y   build-essential   libssl-dev   openssl   pk  8.2s
 => [5/7] RUN mkdir -p /lib/steel/                                                          0.4s
 => [6/7] RUN cargo build                                                                  44.9s 
 => [7/7] RUN cargo run -- cogs/install.scm                                                 1.5s 
 => exporting to image                                                                      6.4s 
 => => exporting layers                                                                     6.4s 
 => => writing image sha256:f39dcc7ff32f2326b46900d1d38a798fe3197591d23bb52931d8b44619bf6d  0.0s 

I also added a .dockerignore with the following contents:

target/
kskarthik commented 9 months ago

yeah, strange! it's working now

BTW STEEL_HOME is only required during build, right ?

mattwparas commented 9 months ago

It's used to resolve installed modules, so it's not used during any execution, but it's used when compiling steel code to bytecode. So if you want to use globally installed modules then you'll need it

kskarthik commented 9 months ago

Finally! done

image