Commit c497d37f authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼

ci: build production docker images for kubernetes deployment

parent d03d7bac
variables:
GIT_SUBMODULE_STRATEGY: normal
DOCKER_TAG: ${CI_COMMIT_REF_NAME}
DOCKER_IMAGE_DEV: villas/web-dev:${CI_COMMIT_REF_NAME}
DOCKER_IMAGE_DEV: node:12.2
DOCKER_IMAGE: ${CI_REGISTRY}/acs/public/villas/web
cache:
untracked: true
......@@ -13,20 +13,12 @@ cache:
- .yarn
stages:
- prepare
- build
- test
# - deploy
prepare:
stage: prepare
script:
- docker build -t ${DOCKER_IMAGE_DEV} -f packaging/docker/Dockerfile.dev .
tags:
- linux
- shell
- deploy
build_job:
build:
stage: build
before_script:
- mkdir -p build
......@@ -41,26 +33,26 @@ build_job:
tags:
- docker
test_job:
test:
stage: test
script:
- npm test
image: ${DOCKER_IMAGE_DEV}
dependencies:
- build_job
- build
tags:
- docker
#deploy:docker:
# stage: deploy
# script:
# - docker build -t ${DOCKER_IMAGE} -f packaging/docker/Dockerfile .
# - docker tag villas/web:${DOCKER_TAG} villas/web:latest
# - docker push villas/web:${DOCKER_TAG}
# - docker push villas/web:latest
# tags:
# - shell
# - linux
# only:
# refs:
# - master
deploy:docker:
stage: deploy
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- docker build -t ${DOCKER_IMAGE} .
- docker push ${DOCKER_IMAGE}
tags:
- shell
- linux
only:
refs:
- master
packaging/docker/Dockerfile
\ No newline at end of file
FROM node:12.2 AS builder
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# use changes to package.json to force Docker not to use the cache
# when we change our application's nodejs dependencies:
ADD package.json /usr/src/app
RUN npm install
# Install app dependencies
COPY . /usr/src/app
RUN npm run build
FROM nginx
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
FROM node:12.2 AS builder
RUN apt-get install -y \
git
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# use changes to package.json to force Docker not to use the cache
# when we change our application's nodejs dependencies:
ADD package.json /usr/src/app
RUN npm install
# Install app dependencies
COPY . /usr/src/app
RUN npm run build
FROM nginx
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
FROM node:12.2
RUN apt-get install -y \
git
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment