Skip to content

Commit

Permalink
Docker build refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nanawel committed May 6, 2021
1 parent 60100e5 commit a07f47c
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
**/node_modules
**/node_modules
.history/
doc/
docker/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/node_modules
*.bak
.history
.history
.vscode
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build_image:
stage: build
script:
- time make config
- time make build args="--build-arg version=${CI_COMMIT_REF_SLUG} --build-arg build_id=${CI_COMMIT_SHORT_SHA}"
- time make build args="--build-arg build_version=${CI_COMMIT_REF_SLUG} --build-arg build_id=${CI_COMMIT_SHORT_SHA} --build-arg build_date=$(date -Is)"
- time docker tag ${APP_IMAGE}:${APP_VERSION:-latest} ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
- time docker push ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
tags:
Expand Down
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ARG node_version="15"
ARG node_variant="-alpine"
ARG version
ARG build_version
ARG build_id
ARG build_date

FROM node:${node_version}${node_variant} as client-builder

Expand All @@ -13,16 +14,20 @@ RUN cd /app/client \

FROM node:${node_version}${node_variant}

ARG version
ARG build_version
ARG build_id
ARG build_date

LABEL app-name="Our Shopping List"
LABEL maintainer="Anaël Ollier <[email protected]>"
LABEL org.label-schema.name="Our Shopping List"
LABEL org.label-schema.vcs-url="https://github.com/nanawel/our-shopping-list"
LABEL org.label-schema.vendor="Anaël Ollier <[email protected]>"
LABEL org.label-schema.version="${build_version}#${build_id}"
LABEL org.label-schema.build-date="${build_date}"

ENV APP_VERSION=${version}
ENV APP_VERSION=${build_version}
ENV APP_BUILD_ID=${build_id}

COPY ./ /app
COPY ./server/ /app
COPY --from=client-builder /app/client /app/client

WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dev-%: export COMPOSE_FILE = docker-compose.yml:docker-compose.dev.yml
dev-%: export COMPOSE_FILE = docker-compose.dev.yml
dev-%: export NODE_BIN = /app/node_modules/nodemon/bin/nodemon.js
dev-%:
$(MAKE) $*
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ The current implementation provides the following features:
- [PWA](https://en.wikipedia.org/wiki/Progressive_web_application) basic support

But, at this date it lacks the following:
- Multi-account support[^1]
- Multi-account support _(it means that a server instance currently exposes
**all** lists to **all** users/clients, since there's no concept of
"user account" yet)_
- Full PWA support with offline mode and deferred sync

[^1]: It means that a server instance currently exposes **all** lists to **all**
users/clients, since there's no concept of "user account" yet.

## Screenshots

### Mobile
Expand Down Expand Up @@ -77,8 +76,8 @@ docker run --detach \

### :whale: With `docker-compose`

Use the provided [`docker-compose.yml`](docker-compose.yml) and adapt it to your
needs (you might want to take a look to the [`.env`](.env) file too).
Use the provided [`docker-compose.yml`](doc/docker-compose.yml) and adapt it to
your needs.

Then to run:

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml → doc/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- mongodb

mongodb:
image: mongo:4-bionic
image: mongo:4
volumes:
- dbdata:/data/db

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ services:
build:
context: './'
args:
version: 'dev'
build_version: 'dev'
build_id: '(unknown build)'
15 changes: 14 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,18 @@ services:
app:
image: node:${node_version}${node_variant_dev}
command: sh -c 'cd /app && ${NODE_BIN:-node} server.js'
ports:
- '8080:8080'
volumes:
- ./:/app
- ./server:/app
- ./client:/app/client
depends_on:
- mongodb

mongodb:
image: mongo:4
volumes:
- dbdata:/data/db

volumes:
dbdata:
14 changes: 14 additions & 0 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Docker Hub build script

set -x

build_version="${DOCKER_TAG:-dev}"
build_id="${SOURCE_COMMIT:0:8}"
build_date="$(date -Is)"

docker build -t $IMAGE_NAME \
--build-arg build_version="${build_version}" \
--build-arg build_id="${build_id}" \
--build-arg build_date="${build_date}" \
.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a07f47c

Please sign in to comment.