Skip to content

Commit a2cd1ff

Browse files
Reduce size of factor image (#15)
We now compile a headless Factor image with no GUI (ui, ui.tools)
1 parent cf38172 commit a2cd1ff

5 files changed

Lines changed: 23 additions & 12 deletions

File tree

Dockerfile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@ RUN git clone https://github.com/factor/factor.git && \
1818
cd factor && \
1919
git checkout ${FACTOR_COMMIT}
2020
WORKDIR /opt/factor
21-
RUN ./build.sh update
21+
22+
# Bootstrap a headless image: drop the GUI (ui, ui.tools), the in-image help
23+
# system (help, handbook), and the dev-tools component (tools) from the bootstrap
24+
# component set.
25+
ARG FACTOR_EXCLUDE="ui ui.tools help handbook tools"
26+
RUN sed -i 's#-i="\$BOOT_IMAGE"#-i="$BOOT_IMAGE" -exclude="'"${FACTOR_EXCLUDE}"'"#' build.sh
27+
28+
# build the pinned commit with no git pull.
29+
RUN ./build.sh net-bootstrap
30+
31+
# Precompile tools.test AND the common exercise vocabs into factor.image, then re-save it.
32+
RUN ./factor -e='USING: accessors arrays ascii assocs calendar calendar.english combinators combinators.short-circuit command-line concurrency.combinators concurrency.locks continuations debugger deques destructors dlists formatting fry generic grouping hash-sets hashtables io io.encodings.utf8 io.files io.streams.string kernel lexer locals macros make math math.bitwise math.combinatorics math.constants math.functions math.order math.parser math.primes math.statistics namespaces prettyprint.config quotations random random.mersenne-twister ranges regexp sequences sets sorting source-files.errors.debugger splitting splitting.monotonic strings system tools.test typed unicode vectors vocabs vocabs.loader memory ; save'
2233

2334
# Remove files not needed at runtime
2435
RUN rm -rf .git build vm src misc Factor.app \
@@ -52,7 +63,7 @@ RUN rm -rf .git build vm src misc Factor.app \
5263
# porter-stemmer, regexp, simple-tokenizer, tr, wrap
5364
# - Editor / interactive only: documents, inspector, listener, see, xdg
5465
# - Other unused: xmode (syntax highlighting), game, farkup (markup),
55-
# calendar, colors, delegate, escape-strings, etc-hosts, eval, interpolate,
66+
# colors, delegate, escape-strings, etc-hosts, eval, interpolate,
5667
# ip-parser, logging, memoize, method-chains, mirrors, models, nmake, ntp,
5768
# protocols, quoting, refs, retries, roman, simple-flat-file, system-info,
5869
# timers, typed, uuid, validators
@@ -76,11 +87,11 @@ RUN cd basis && rm -rf \
7687
unrolled-lists vlists \
7788
globs lcs match peg porter-stemmer regexp simple-tokenizer tr wrap \
7889
documents inspector listener see xdg \
79-
calendar colors delegate escape-strings etc-hosts eval interpolate \
90+
colors delegate escape-strings etc-hosts eval interpolate \
8091
ip-parser logging memoize method-chains mirrors models nmake ntp \
8192
protocols quoting refs retries roman simple-flat-file system-info \
8293
timers typed uuid validators \
83-
bootstrap environment persistent random
94+
bootstrap environment persistent
8495

8596
# Asian and rare encodings: only utf8 / latin1 / strict are kept (everything
8697
# bundled streams use). 8-bit is the multi-codepage non-utf umbrella.

tests/concept-success/concept-success/concept-success-tests.factor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TASK: 1 numbers
77
STOP-HERE
88

99
TASK: 2 strings
10-
{ "hello" } [ string-result dup . ] unit-test
10+
{ "June" } [ string-result dup . ] unit-test
1111

1212
TASK: 3 arrays
1313
{ { 1 2 3 } } [ array-result ] unit-test

tests/concept-success/concept-success/concept-success.factor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
USING: accessors combinators fry hash-sets hashtables kernel
2-
locals math sequences vectors ;
1+
USING: accessors calendar.english combinators fry hash-sets hashtables
2+
kernel locals math sequences vectors ;
33
IN: concept-success
44

55
TUPLE: point x y ;
66

77
: number-result ( -- n ) 42 ;
88

9-
: string-result ( -- s ) "hello" ;
9+
: string-result ( -- s ) 6 month-name ;
1010

1111
: array-result ( -- arr ) { 1 2 3 } ;
1212

tests/concept-success/expected_results.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
{
1313
"name": "Test 2",
1414
"status": "pass",
15-
"test_code": "{ \"hello\" } [ string-result dup . ] unit-test",
15+
"test_code": "{ \"June\" } [ string-result dup . ] unit-test",
1616
"task_id": 2,
17-
"output": "\"hello\""
17+
"output": "\"June\""
1818
},
1919
{
2020
"name": "Test 3",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
USING: kernel ;
1+
USING: formatting kernel ;
22
IN: success
33

4-
: greet ( -- str ) "hello" ;
4+
: greet ( -- str ) "h" "%sello" sprintf ;

0 commit comments

Comments
 (0)