Commit 3801e52c authored by adietmue's avatar adietmue
Browse files

Update ci script and add dockerfile

parent 0b6de382
image: node:latest
stages:
- lint
- test
- build
before_script:
- npm install
- echo "$CONFIGURATION" > src/models/config.js
- deploy
eslint:
stage: lint
when: always
stage: test
image: node:latest
before_script:
- npm install
script:
- npm run lint
build_master:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" ./
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
# On branches except master: verify that build works, do not push to registry
build:
stage: build
when: always
image: docker:latest
services:
- docker:dind
script:
- docker build --pull ./
except:
- master
deploy:
stage: deploy
image: amiveth/service-update-helper
script:
- npm run build
- /update.py
only:
- master
# This Dockerfile uses a multi-stage build. Only the first stage requires
# all dependencies, the final image will contain only the output files
# First stage: Build project
FROM node as build
# Copy files and install dependencies
COPY ./ /
RUN npm install
# Build project
RUN npm run build
# Second stage: Server to deliver files
FROM node:alpine
# Install http server
RUN npm install --global --no-save http-server
# Port 8080 can be used as non root
EXPOSE 8080
# Create user with home directory and no password
RUN adduser -Dh /public server
USER server
WORKDIR /public
# Copy files from first stage
COPY --from=build /index.html /public/
COPY --from=build /dist /public/dist
# Run server (-g will automatically serve the gzipped files if possible)
CMD ["/usr/local/bin/http-server", "-g", "/public"]
Supports Markdown
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