Skip to content

Commit 10a03c8

Browse files
committed
testing dockerhub hooks
1 parent 036a141 commit 10a03c8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,11 @@ RUN npm run prepare && npm run postinstall
4444
# list all dir/files - for debugging purposes
4545
# RUN ls -al
4646

47-
# ---- UNIT TESTS AND FLOW LINT in stage 3------
47+
# UNIT TESTS
48+
# if you want to perform unit testing, do it in the build stage (tests won't be cached, since the build stage cache is invalidated when files change)
4849
# do not run flow through npm - https://github.com/facebook/flow/issues/3649
49-
# RUN apk add --no-cache --repository https://nl.alpinelinux.org/alpine/edge/testing flow
50-
# run unit tests after COPY - any file change will invalidated cached layer and guarantees a new test run
51-
# make sure flow is removed from pretest in package.json
5250
# RUN npm test
5351

54-
5552
# ------- Stage 4 - Release ---------
5653
FROM dependencies AS release
5754
# lib is the output from babel in the build step
@@ -66,8 +63,9 @@ COPY /views ./views
6663
# RUN ls -al
6764

6865
# capture git_commit in label
69-
ARG GIT_COMMIT
70-
LABEL git_commit=$GIT_COMMIT
66+
# This is used in the script in /hooks/build.sh which is a trigger used in dockerhub builds
67+
# ARG SOURCE_COMMIT
68+
# LABEL SOURCE_COMMIT=$SOURCE_COMMIT
7169

7270
# run as non-root. USER node is provided with node images
7371
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#non-root-user
@@ -80,7 +78,8 @@ EXPOSE 1337
8078
# start with node, not npm
8179
ENTRYPOINT ["node", "./bin/parse-server", "--"]
8280

83-
# BUILD: docker build -t parse-platform/parse-server:test --build-arg GIT_COMMIT=$(git log -1 --format=%H) .
81+
# BUILD: docker build -t parse-platform/parse-server:test --build-arg SOURCE_COMMIT=$(git log -1 --format=%H) .
82+
# docker build -t local/parse-server:local --build-arg GIT_COMMIT=$(git log -1 --format=%H) .
8483
# RUN (entrypoint sh): sudo docker run --name parse-server --rm -it --entrypoint sh barakbd/parse-server:test
8584
# to stop at a specific steps add --target flag
8685
# sudo docker build --target release -t barakbd/parse-server:test .

hooks/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# https://medium.com/microscaling-systems/labelling-automated-builds-on-docker-hub-f3d073fb8e1
2+
# https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing
3+
4+
#!/bin/bash
5+
echo "=> Building the binary"
6+
docker build --label SOURCE_COMMIT=$SOURCE_COMMIT -f $DOCKERFILE_PATH -t $IMAGE_NAME .

0 commit comments

Comments
 (0)