Skip to content

Commit

Permalink
Improve dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz-lisowski committed Jun 24, 2024
1 parent 10f875e commit 3e330bf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Compiler output
# Compiler output.
build/
build-lib/

# Clangd config
# Clangd config.
compile_flags.txt

# Ignore example
# Ignore example.
example/

# Docker output.
docker/
docker.log
7 changes: 7 additions & 0 deletions docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -o nounset; # Abort on unbound variable.
set -o pipefail; # Don't hide errors within pipes.
set -o errexit; # Abort on non-zero exit status.

docker build --progress=plain . -t tomasz-lisowski/swicc:1.0.0 2>&1 | tee docker.log;
docker run -v ./docker:/opt/out --tty --interactive --rm tomasz-lisowski/swicc:1.0.0;
16 changes: 11 additions & 5 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# docker build --progress=plain . -t tomasz-lisowski/swicc:1.0.0 2>&1 | tee build.log;
# docker run -v ./build:/opt/swicc/build/host --tty --rm tomasz-lisowski/swicc:1.0.0;

FROM ubuntu:22.04 AS base

RUN set -eux; \
apt-get -qq update; \
apt-get -qq --yes dist-upgrade;


FROM base AS base__swicc
COPY . /opt/swicc
ENV DEP="cmake gcc gcc-multilib make"
Expand All @@ -17,6 +15,14 @@ RUN set -eux; \
make -j $(nproc) main-static test-static; \
apt-get -qq --yes purge ${DEP};


FROM base
COPY --from=base__swicc /opt/swicc/build /opt/swicc/build/local
ENTRYPOINT [ "/bin/bash", "-c", "(cp -r /opt/swicc/build/local/*.a /opt/swicc/build/host) && (cp -r /opt/swicc/build/local/*.elf /opt/swicc/build/host) && (mkdir -p /opt/swicc/build/host/tmp)" ]
COPY --from=base__swicc /opt/swicc/build /opt/swicc/build
COPY --from=base__swicc /opt/swicc/test/data /opt/swicc/test/data

RUN set -eux; \
rm -r /opt/swicc/build/swicc; \
rm -r /opt/swicc/build/test; \
rm -r /opt/swicc/build/cjson;

ENTRYPOINT [ "bash", "-c", "cp -r /opt/swicc/* /opt/out" ]

0 comments on commit 3e330bf

Please sign in to comment.