-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from KyeRussell/build-improvements
Improved Docker image build / sandbox setup process
- Loading branch information
Showing
2 changed files
with
89 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,49 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM ubuntu:22.04 | ||
|
||
RUN apt update -y --fix-missing | ||
RUN apt install -y --fix-missing python3 gcc python3-dev python3-pip ruby-full rubygems-integration musl-dev protobuf-compiler git ruby-full libmagic-dev strace curl autoconf build-essential libfreetype-dev libssl-dev gawk | ||
RUN gem install parser:3.0.0.0 google-protobuf:3.21.2 rubocop:1.31.1 | ||
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs | ||
# Set up local user | ||
RUN groupadd -g 1001 ubuntu && \ | ||
useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -u 1001 ubuntu | ||
|
||
# Enable the apt downloaded packages cache, so we can hook it up to a Docker | ||
# BuildKit cache to speed up subsequent image builds. | ||
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \ | ||
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache | ||
|
||
# Add upstream Node.js apt repository | ||
ADD --chmod=755 https://deb.nodesource.com/setup_16.x /tmp/setup_16.x | ||
|
||
# Install OS (apt) dependencies | ||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
--mount=type=cache,target=/var/lib/apt,sharing=locked \ | ||
/tmp/setup_16.x && \ | ||
apt-get install --quiet --yes python3 gcc python3-dev python3-pip ruby-full rubygems-integration musl-dev protobuf-compiler git ruby-full libmagic-dev strace curl autoconf build-essential libfreetype-dev libssl-dev gawk nodejs | ||
|
||
RUN groupadd -g 1001 ubuntu | ||
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -u 1001 ubuntu | ||
# Install Ruby dependencies | ||
RUN --mount=type=cache,target=/root/.gem,sharing=locked \ | ||
gem install parser:3.0.0.0 google-protobuf:3.21.2 rubocop:1.31.1 | ||
|
||
# Install pip dependencies | ||
COPY requirements.txt requirements.txt | ||
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \ | ||
pip3 install --upgrade --progress-bar off --disable-pip-version-check -r requirements.txt | ||
|
||
# Set up Packj sandbox tool | ||
COPY ./packj/sandbox /tmp/sandbox-install | ||
RUN cd /tmp/sandbox-install && \ | ||
./install.sh -v && \ | ||
mv /tmp/sandbox-install/libsbox.so /tmp && \ | ||
rm -rf /tmp/sandbox-install | ||
|
||
WORKDIR /home/ubuntu/packj | ||
|
||
COPY --chown=ubuntu:ubuntu . . | ||
RUN pip3 install -r requirements.txt && cd packj/sandbox && ./install.sh && mkdir /home/ubuntu/.local /home/ubuntu/.ruby /home/ubuntu/.npm /home/ubuntu/.npm/_cacache && chown -R ubuntu:ubuntu /home/ubuntu | ||
RUN mv /tmp/libsbox.so /home/ubuntu/packj/packj/sandbox/libsbox.so | ||
|
||
RUN cd /home/ubuntu && \ | ||
mkdir .local ruby .npm .npm/_cacache && \ | ||
chown -R ubuntu:ubuntu /home/ubuntu | ||
|
||
USER ubuntu | ||
ENTRYPOINT ["python3", "main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters