Skip to content

Commit 70e2a69

Browse files
lcobucciPhil Sturgeon
authored and
Phil Sturgeon
committedNov 19, 2018
Publish image automatically (#205)
* Build docker image for every commit In order to make sure that we don't introduce any issue on PRs. * Publish docker images automatically From now on, every merge will update the `nightly` docker tag and tagged jobs will create a docker tag with the same name of the git tag and also update the `latest` docker tag. * Build the image from source instead To allow us to replay the build of a revision as many times as we want and prevent possible version inconsistencies. * Expose default port by default Which allows the command "serve" to be used via docker too. * Validate docker image on CI
1 parent e28b49f commit 70e2a69

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed
 

‎.circleci/config.yml

+28
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ jobs:
4242
- image: circleci/node:8
4343
<<: *shared
4444

45+
build-image:
46+
machine: true
47+
steps:
48+
- checkout
49+
- run: docker run --rm -i hadolint/hadolint < Dockerfile
50+
- run: docker build -t speccy:$CIRCLE_SHA1 .
51+
52+
push-image:
53+
machine: true
54+
steps:
55+
- checkout
56+
- run: docker build -t speccy:$CIRCLE_SHA1 .
57+
- run: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
58+
- run: docker tag speccy:$CIRCLE_SHA1 wework/speccy:nightly
59+
- run: if [ "$CIRCLE_TAG" != "" ]; then docker tag speccy:$CIRCLE_SHA1 wework/speccy:latest; fi;
60+
- run: if [ "$CIRCLE_TAG" != "" ]; then docker tag speccy:$CIRCLE_SHA1 wework/speccy:$CIRCLE_TAG; fi;
61+
4562
workflows:
4663
version: 2
4764
commit:
@@ -50,3 +67,14 @@ workflows:
5067
- node-10
5168
- node-9
5269
- node-8
70+
- build-image
71+
72+
deploy:
73+
jobs:
74+
- push-image:
75+
filters:
76+
branches:
77+
only: master
78+
tags:
79+
only: /.*/
80+

‎.dockerignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/.circleci
2+
/.git
3+
/.github
4+
/*.md
5+
/Dockerfile
6+
/docs
7+
/.dockerignore
8+
/.editorconfig
9+
/.eslintrc.json
10+
/.gitignore
11+
/test
12+

‎Dockerfile

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
FROM node:11.1-alpine as builder
2+
3+
WORKDIR /opt/speccy
4+
5+
COPY . /opt/speccy/
6+
7+
ENV NODE_ENV=production
8+
9+
# Ignore version locking to avoid undesired breaks due to changes in upstream
10+
# hadolint ignore=DL3018
11+
RUN apk add --no-cache git \
12+
&& npm install
13+
114
FROM node:11.1-alpine
215

3-
RUN apk add --no-cache --virtual .build_deps git \
4-
&& npm install --global speccy \
5-
&& apk del .build_deps
16+
COPY --from=builder /opt/speccy/ /opt/speccy/
17+
18+
RUN ln -s /opt/speccy/speccy.js /usr/local/bin/speccy
619

720
WORKDIR /project
821

22+
EXPOSE 5000
923
ENTRYPOINT ["speccy"]
1024
CMD ["-h"]
1125

0 commit comments

Comments
 (0)
Please sign in to comment.