Skip to content

Commit 70069f7

Browse files
feat(ci): add Dockerfile and accompanying Habitat plan
1 parent 424582d commit 70069f7

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

Dockerfile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This Dockerfile is hyper-optimized to minimize layer changes
2+
3+
FROM jarvus/habitat-compose:latest as habitat
4+
5+
ARG HAB_LICENSE=no-accept
6+
ENV HAB_LICENSE=$HAB_LICENSE
7+
ENV STUDIO_TYPE=Dockerfile
8+
ENV HAB_ORIGIN=codeforphilly
9+
RUN hab origin key generate
10+
11+
# pre-layer all external runtime plan deps
12+
COPY habitat/plan.sh /habitat/plan.sh
13+
RUN hab pkg install \
14+
core/bash \
15+
emergence/php-runtime \
16+
$({ cat '/habitat/plan.sh' && echo && echo 'echo "${pkg_deps[@]/$pkg_origin\/*/}"'; } | hab pkg exec core/bash bash) \
17+
&& hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/
18+
19+
# pre-layer all external runtime composite deps
20+
COPY habitat/composite/plan.sh /habitat/composite/plan.sh
21+
RUN hab pkg install \
22+
jarvus/habitat-compose \
23+
emergence/nginx \
24+
$({ cat '/habitat/composite/plan.sh' && echo && echo 'echo "${pkg_deps[@]/$pkg_origin\/*/} ${composite_mysql_pkg}"'; } | hab pkg exec core/bash bash) \
25+
&& hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/
26+
27+
28+
FROM habitat as projector
29+
30+
# pre-layer all build-time plan deps
31+
RUN hab pkg install \
32+
core/hab-plan-build \
33+
jarvus/hologit \
34+
jarvus/toml-merge \
35+
$({ cat '/habitat/plan.sh' && echo && echo 'echo "${pkg_build_deps[@]/$pkg_origin\/*/}"'; } | hab pkg exec core/bash bash) \
36+
&& hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/
37+
38+
# pre-layer all build-time composite deps
39+
RUN hab pkg install \
40+
jarvus/toml-merge \
41+
$({ cat '/habitat/composite/plan.sh' && echo && echo 'echo "${pkg_build_deps[@]/$pkg_origin\/*/}"'; } | hab pkg exec core/bash bash) \
42+
&& hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/
43+
44+
# build application
45+
COPY . /src
46+
ARG SITE_TREE
47+
ENV SITE_TREE=$SITE_TREE
48+
ARG SITE_VERSION
49+
ENV SITE_VERSION=$SITE_VERSION
50+
RUN hab pkg exec core/hab-plan-build hab-plan-build /src
51+
RUN hab pkg exec core/hab-plan-build hab-plan-build /src/habitat/composite
52+
53+
54+
FROM habitat as runtime
55+
56+
# configure persistent volumes
57+
RUN hab pkg exec core/coreutils mkdir -p '/hab/svc/mysql/data' '/hab/svc/laddr/data' '/hab/svc/nginx/files' \
58+
&& hab pkg exec core/coreutils chown hab:hab -R '/hab/svc/mysql/data' '/hab/svc/laddr/data' '/hab/svc/nginx/files'
59+
60+
# configure entrypoint
61+
VOLUME ["/hab/svc/mysql/data", "/hab/svc/laddr/data", "/hab/svc/nginx/files"]
62+
ENTRYPOINT ["hab", "sup", "run"]
63+
CMD ["codeforphilly/laddr-composite"]
64+
65+
# install .hart artifact from builder stage
66+
COPY --from=projector /hab/cache/artifacts/$HAB_ORIGIN-* /hab/cache/artifacts/
67+
RUN hab pkg install /hab/cache/artifacts/$HAB_ORIGIN-* \
68+
&& hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/
69+
70+
# add source metadata to environment
71+
ARG SOURCE_TAG
72+
ENV SOURCE_TAG=$SOURCE_TAG
73+
ARG SOURCE_COMMIT
74+
ENV SOURCE_COMMIT=$SOURCE_COMMIT

habitat/composite/default.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[services.app.config]
2+
default_timezone = "America/New_York"

habitat/composite/plan.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
composite_app_pkg_name=laddr
2+
pkg_name="${composite_app_pkg_name}-composite"
3+
pkg_origin=codeforphilly
4+
pkg_maintainer="Code for Philly <[email protected]>"
5+
pkg_scaffolding=emergence/scaffolding-composite
6+
composite_mysql_pkg=core/mysql
7+
8+
pkg_version() {
9+
scaffolding_detect_pkg_version
10+
}

habitat/default.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[sites.default]
2+
database = "laddr"

habitat/plan.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pkg_name=laddr
2+
pkg_origin=codeforphilly
3+
pkg_maintainer="Code for Philly <[email protected]>"
4+
pkg_scaffolding=emergence/scaffolding-site
5+
6+
pkg_version() {
7+
scaffolding_detect_pkg_version
8+
}

0 commit comments

Comments
 (0)