-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(Dockerfile): attempt to fix github ci
- Loading branch information
Showing
5 changed files
with
68 additions
and
79 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,84 +1,73 @@ | ||
ARG CRYSTAL_VERSION=1.0.0 | ||
FROM crystallang/crystal:${CRYSTAL_VERSION} as build | ||
ARG PLACE_COMMIT="DEV" | ||
|
||
ARG PLACE_COMMIT=DEV | ||
FROM crystallang/crystal:${CRYSTAL_VERSION} as build | ||
|
||
WORKDIR /app | ||
|
||
RUN apt update | ||
RUN apt install --no-install-recommends -y \ | ||
RUN apt-get update && \ | ||
apt-get install -y apt-transport-https && \ | ||
apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive \ | ||
apt install --no-install-recommends -y \ | ||
bash \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
libssh2-1 libssh2-1-dev \ | ||
libgc-dev \ | ||
llvm-10 llvm-10-dev \ | ||
tzdata | ||
libssh2-1 libssh2-1-dev \ | ||
libyaml-dev \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Add trusted CAs for communicating with external services | ||
RUN update-ca-certificates | ||
|
||
SHELL ["/bin/bash", "-l", "-c"] | ||
|
||
# Install asdf version manager | ||
RUN git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.8.0 | ||
RUN $HOME/.asdf/bin/asdf plugin-add crystal https://github.com/asdf-community/asdf-crystal.git | ||
|
||
RUN echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \ | ||
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.profile && \ | ||
source ~/.bashrc | ||
|
||
# Create a non-privileged user | ||
ARG IMAGE_UID="10001" | ||
ENV UID=$IMAGE_UID | ||
ENV USER=appuser | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
# These provide certificate chain validation where communicating with external services over TLS | ||
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt | ||
|
||
# Create binary directories | ||
RUN mkdir -p repositories bin/drivers | ||
# Install watchexec | ||
RUN curl -sLO https://github.com/watchexec/watchexec/releases/download/cli-v1.16.0/watchexec-1.16.0-x86_64-unknown-linux-gnu.deb && \ | ||
dpkg -i watchexec-1.16.0-x86_64-unknown-linux-gnu.deb && \ | ||
rm -rf ./*.deb | ||
|
||
RUN mkdir /app/.shards | ||
RUN mkdir -p /app/bin/drivers | ||
|
||
# Install deps | ||
# Install shards before adding source. | ||
COPY shard.yml /app | ||
COPY shard.lock /app | ||
RUN shards install --ignore-crystal-version | ||
|
||
RUN shards install --production --ignore-crystal-version | ||
|
||
# Copy source for the long building `digest_cli` | ||
RUN mkdir /app/src | ||
# Build digest tool before copying rest of source for better caching. | ||
COPY src/digest_cli.cr /app/src/digest_cli.cr | ||
|
||
RUN CRYSTAL_PATH=lib:/usr/share/crystal/src/ \ | ||
LLVM_CONFIG=$(/usr/share/crystal/src/llvm/ext/find-llvm-config) \ | ||
PLACE_COMMIT=${PLACE_COMMIT} \ | ||
UNAME_AT_COMPILE_TIME=true \ | ||
shards build --error-trace --ignore-crystal-version --release --production -Dpreview_mt digest_cli | ||
shards build digest_cli -Dpreview_mt --ignore-crystal-version --no-debug --production | ||
|
||
COPY scripts /app/scripts | ||
COPY src /app/src | ||
|
||
# Add the rest of the source last for efficient caching | ||
COPY src /app/src | ||
|
||
RUN PLACE_COMMIT=${PLACE_COMMIT} \ | ||
UNAME_AT_COMPILE_TIME=true \ | ||
shards build --error-trace --ignore-crystal-version --release --production -Dpreview_mt build | ||
shards build --error-trace -Dpreview_mt --release --ignore-crystal-version --production build | ||
|
||
RUN chown appuser -R /app | ||
|
||
ENV HOME="/app" | ||
|
||
# Install asdf version manager | ||
SHELL ["/bin/bash", "-l", "-c"] | ||
RUN git clone --depth 1 https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.8.0 && \ | ||
$HOME/.asdf/bin/asdf plugin-add crystal https://github.com/asdf-community/asdf-crystal.git && \ | ||
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \ | ||
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.profile && \ | ||
source ~/.bashrc | ||
|
||
############################################################################### | ||
|
||
USER appuser:appuser | ||
|
||
# These provide certificate chain validation where communicating with external services over TLS | ||
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt | ||
|
||
EXPOSE 3000 | ||
HEALTHCHECK CMD wget -qO- http://localhost:3000/api/build/v1 | ||
CMD ["/app/scripts/entrypoint.sh", "--server", "-b", "0.0.0.0", "-p", "3000"] |
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,59 +1,58 @@ | ||
ARG CRYSTAL_VERSION=1.0.0 | ||
FROM crystallang/crystal:${CRYSTAL_VERSION} | ||
|
||
ARG PLACE_COMMIT="DEV" | ||
|
||
FROM crystallang/crystal:${CRYSTAL_VERSION} as build | ||
|
||
WORKDIR /app | ||
|
||
RUN apt update | ||
RUN apt install --no-install-recommends -y \ | ||
RUN apt-get update && \ | ||
apt-get install -y apt-transport-https && \ | ||
apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive \ | ||
apt install --no-install-recommends -y \ | ||
bash \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
libssh2-1 libssh2-1-dev \ | ||
llvm-10 llvm-10-dev \ | ||
tzdata | ||
libssh2-1 libssh2-1-dev \ | ||
libyaml-dev \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Add trusted CAs for communicating with external services | ||
RUN update-ca-certificates | ||
|
||
# Install watchexec | ||
RUN curl -sLO https://github.com/watchexec/watchexec/releases/download/cli-v1.16.0/watchexec-1.16.0-x86_64-unknown-linux-gnu.deb && \ | ||
dpkg -i watchexec-1.16.0-x86_64-unknown-linux-gnu.deb && \ | ||
rm -rf ./*.deb | ||
|
||
# Add trusted CAs for communicating with external services | ||
RUN update-ca-certificates | ||
|
||
SHELL ["/bin/bash", "-l", "-c"] | ||
|
||
# Install asdf version manager | ||
RUN git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.8.0 | ||
RUN $HOME/.asdf/bin/asdf plugin-add crystal https://github.com/asdf-community/asdf-crystal.git | ||
|
||
RUN echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \ | ||
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.profile && \ | ||
source ~/.bashrc | ||
RUN mkdir -p /app/bin/drivers | ||
|
||
# Install shards before adding source. | ||
COPY shard.yml /app | ||
COPY shard.lock /app | ||
RUN shards install --ignore-crystal-version | ||
|
||
# Build digest tool before copying rest of source for better caching. | ||
RUN mkdir /app/src | ||
COPY src/digest_cli.cr /app/src/digest_cli.cr | ||
|
||
RUN CRYSTAL_PATH=lib:/usr/share/crystal/src/ \ | ||
LLVM_CONFIG=$(/usr/share/crystal/src/llvm/ext/find-llvm-config) \ | ||
shards build digest_cli --ignore-crystal-version --no-debug | ||
|
||
COPY src/digest_cli.cr /app/src/digest_cli.cr | ||
shards build digest_cli -Dpreview_mt --ignore-crystal-version --no-debug --production | ||
|
||
COPY scripts /app/scripts | ||
COPY src /app/sr | ||
|
||
RUN mkdir -p /app/bin/drivers | ||
COPY src /app/src | ||
|
||
# These provide certificate chain validation where communicating with external services over TLS | ||
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt | ||
|
||
SHELL ["/bin/bash", "-l", "-c"] | ||
ENV HOME="/app" | ||
# Install asdf version manager | ||
RUN git clone --depth 1 https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.8.0 && \ | ||
$HOME/.asdf/bin/asdf plugin-add crystal https://github.com/asdf-community/asdf-crystal.git && \ | ||
echo -e '\n. $HOME/.asdf/asdf.sh' >> $HOME/.bashrc && \ | ||
echo -e '\n. $HOME/.asdf/asdf.sh' >> $HOME/.profile && \ | ||
source ~/.bashrc | ||
|
||
|
||
CMD /app/scripts/entrypoint-test.sh |
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
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
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