Add build config

This commit is contained in:
Anton Vakhrushev 2019-11-09 20:47:00 +03:00
parent 4f727d10d3
commit 5542621de7
6 changed files with 79 additions and 13 deletions

View File

@ -1,13 +1,55 @@
version: 2.1
jobs:
build:
build_server:
docker:
- image: docker:19.03.4
- image: alpine:3.10.3
steps:
- setup_remote_docker
- checkout
- run: apk add -u make zip git curl
- run: pwd; ls -la; make install
- run: pwd; ls -la; tools/shards install
- run: pwd; ls -la; make spec
- run: pwd; ls -la; make build
- run: ./docker/provide-crystal-alpine
- run: shards install
- run: make spec STAGE=prod
- run: make build STAGE=prod
- persist_to_workspace:
root: build
paths: ['*']
build_assets:
docker:
- image: circleci/node:12.13
steps:
- checkout
- run: npm ci
- run: npm run-script build-prod
- run: ls -la ./public/assets
- persist_to_workspace:
root: public/assets
paths: ['*']
build_docker_image:
docker:
- image: docker:19.03
steps:
- attach_workspace:
at: /tmp/data
- run: ls -la /tmp/data
- checkout
- run: mkdir -p ./build/
- run: cp /tmp/data/dayoff ./build/dayoff
- run: mkdir -p ./public/assets/
- run: cp /tmp/data/main.css /tmp/data/main.js ./public/assets/
- setup_remote_docker
- run: docker build --file ./docker/Dockerfile.prod --tag anwinged/dayoff .
- run: docker login --username "$DOCKER_REG_USERNAME" --password "$DOCKER_REG_PASSWORD"
- run: docker push anwinged/dayoff
workflows:
version: 2
test_and_build:
jobs:
- build_server
- build_assets
- build_docker_image:
requires:
- build_server
- build_assets

View File

@ -1,3 +1,5 @@
/.crystal/
/.shards/
/coverage/
/node_modules/
/var/

View File

@ -1,11 +1,13 @@
PATH := tools:$(PATH)
ifneq ($(STAGE), prod)
PATH := tools:$(PATH)
endif
APP_NAME := dayoff
ENTRY_POINT = ./src/$(APP_NAME).cr
.PHONY: build-docker
build-docker:
docker pull alpine:edge
docker build -t $(APP_NAME)-crystal .
docker build --file docker/Dockerfile.dev --tag $(APP_NAME)-crystal --tag anwinged/$(APP_NAME)-crystal .
install-shards:
shards install

6
docker/Dockerfile.dev Normal file
View File

@ -0,0 +1,6 @@
FROM alpine:3.10.3 as builder
COPY ./docker/provide-crystal-alpine /opt/provision/provide-crystal-alpine
# Install crystal and dev libs
RUN /opt/provision/provide-crystal-alpine

14
docker/Dockerfile.prod Normal file
View File

@ -0,0 +1,14 @@
FROM alpine:3.10.3
ENV BASE_PATH /opt/dayoff
RUN apk add -u tzdata
COPY ./build/dayoff /app/
COPY ./public /app/public/
WORKDIR /app
EXPOSE 3000
CMD ["/app/dayoff"]

4
Dockerfile → docker/provide-crystal-alpine Normal file → Executable file
View File

@ -1,7 +1,7 @@
FROM alpine:3.10.3 as builder
#!/usr/bin/env sh
# Install crystal and dev libs
RUN apk add -u \
apk add -u \
make \
crystal \
shards \