1- FROM 84codes/crystal:latest-alpine AS build
1+ ARG CRYSTAL_VERSION=latest
2+
3+ FROM placeos/crystal:$CRYSTAL_VERSION AS build
24WORKDIR /app
35
6+ # Set the commit via a build arg
7+ ARG PLACE_COMMIT="DEV"
8+ # Set the platform version via a build arg
9+ ARG PLACE_VERSION="DEV"
10+
411# Create a non-privileged user, defaults are appuser:10001
512ARG IMAGE_UID="10001"
613ENV UID=$IMAGE_UID
@@ -16,49 +23,11 @@ RUN adduser \
1623 --uid "${UID}" \
1724 "${USER}"
1825
19- # Add dependencies commonly required for building crystal applications
20- # hadolint ignore=DL3018
21- RUN apk add \
22- --update \
23- --no-cache \
24- gcc \
25- make \
26- autoconf \
27- automake \
28- libtool \
29- patch \
30- ca-certificates \
31- yaml-dev \
32- yaml-static \
33- git \
34- bash \
35- iputils \
36- libelf \
37- gmp-dev \
38- libxml2-dev \
39- musl-dev \
40- pcre-dev \
41- zlib-dev \
42- zlib-static \
43- libunwind-dev \
44- libunwind-static \
45- libevent-dev \
46- libevent-static \
47- libssh2-static \
48- lz4-dev \
49- lz4-static \
50- tzdata \
51- curl
52-
53- # Already included in the image
54- # openssl-dev
55- # openssl-libs-static
26+ # Install package updates since image release
27+ RUN apk update && apk --no-cache --quiet upgrade
5628
5729RUN update-ca-certificates
5830
59- # Install any additional dependencies
60- # RUN apk add libssh2 libssh2-dev
61-
6231# Install shards for caching
6332COPY shard.yml shard.yml
6433COPY shard.override.yml shard.override.yml
@@ -70,10 +39,14 @@ RUN shards install --production --ignore-crystal-version --skip-postinstall --sk
7039COPY ./src /app/src
7140
7241# Build application
73- RUN shards build --production --release --error-trace
42+ RUN UNAME_AT_COMPILE_TIME=true \
43+ PLACE_COMMIT=$PLACE_COMMIT \
44+ PLACE_VERSION=$PLACE_VERSION \
45+ shards build --production --error-trace --static
46+
7447SHELL ["/bin/ash" , "-eo" , "pipefail" , "-c" ]
7548
76- # Extract binary dependencies (uncomment if not compiling a static build)
49+ # Extract binary dependencies
7750RUN for binary in /app/bin/*; do \
7851 ldd "$binary" | \
7952 tr -s '[:blank:]' '\n ' | \
@@ -84,6 +57,8 @@ RUN for binary in /app/bin/*; do \
8457# Generate OpenAPI docs while we still have source code access
8558RUN ./bin/placeos-auth --docs > openapi.yml
8659
60+ RUN git config --system http.sslCAInfo /etc/ssl/certs/ca-certificates.crt
61+
8762# Build a minimal docker image
8863FROM scratch
8964WORKDIR /
@@ -113,7 +88,7 @@ COPY --from=build /app/openapi.yml /openapi.yml
11388# Use an unprivileged user.
11489USER appuser:appuser
11590
116- # Spider-gazelle has a built in helper for health checks (change this as desired for your applications)
91+ # Spider-gazelle has a built in helper for health checks
11792HEALTHCHECK CMD ["/placeos-auth" , "-c" , "http://127.0.0.1:3000/auth/healthz" ]
11893
11994# Run the app binding on port 3000
0 commit comments