mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 19:58:28 +01:00
Base build
This commit is contained in:
parent
d724878c2c
commit
dcc4ec7213
30
.github/workflows/base.yml
vendored
Normal file
30
.github/workflows/base.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: Base image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [base]
|
||||
|
||||
jobs:
|
||||
push:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Log into Github registry
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Build base run image
|
||||
run: |
|
||||
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/base-run:$GITHUB_SHA
|
||||
docker build etc/base-run --tag $IMAGE_ID
|
||||
docker push $IMAGE_ID
|
||||
echo Pushed new base image $IMAGE_ID
|
||||
|
||||
- name: Build base build image
|
||||
run: |
|
||||
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/base-build:$GITHUB_SHA
|
||||
docker build etc/base-build --tag $IMAGE_ID
|
||||
docker push $IMAGE_ID
|
||||
echo Pushed new base build image $IMAGE_ID
|
||||
29
.github/workflows/runtime.yml
vendored
Normal file
29
.github/workflows/runtime.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: Runtime image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
push:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Log into Github registry
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Build image
|
||||
run: docker build . --tag image
|
||||
|
||||
- name: Push to Docker Hub
|
||||
run: |
|
||||
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login --username snoyberg --password-stdin
|
||||
IMAGE_ID=snoyberg/snoyman.com
|
||||
docker tag image $IMAGE_ID
|
||||
docker push $IMAGE_ID
|
||||
IMAGE_ID=$IMAGE_ID:$GITHUB_SHA
|
||||
docker tag image $IMAGE_ID
|
||||
docker push $IMAGE_ID
|
||||
@ -1,67 +0,0 @@
|
||||
image: registry.gitlab.fpcomplete.com/fpco/default-build-image:7293
|
||||
|
||||
cache:
|
||||
key: "$CI_BUILD_NAME"
|
||||
paths:
|
||||
- .stack-work/
|
||||
- .stack-root/
|
||||
- static/combined/
|
||||
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
STACK_ROOT: "${CI_PROJECT_DIR}/.stack-root"
|
||||
DEPLOYMENT_IMAGE: "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF_SLUG}_${CI_PIPELINE_ID}"
|
||||
DEPLOYMENT_NAME: "stackage-server-prod"
|
||||
HOOGLE_DEPLOYMENT_NAME: "stackage-server-hoogle-prod"
|
||||
CRON_DEPLOYMENT_NAME: "stackage-server-cron-prod"
|
||||
DEPLOYMENT_APP: "stackage-server-prod"
|
||||
CRON_DEPLOYMENT_APP: "stackage-server-cron-prod"
|
||||
HOOGLE_DEPLOYMENT_APP: "stackage-server-hoogle-prod"
|
||||
KUBECONFIG: /etc/deploy/kubeconfig.yaml
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
# Clear *_TOKEN variables during code build so that compile-time code can't access them
|
||||
- apt-get update && apt-get install -y --no-install-recommends libpq-dev git rsync
|
||||
- CI_BUILD_TOKEN="" KUBECONFIG_YAML="" KUBE_TOKEN="" PROD_KUBE_TOKEN="" PROD_DOCKER_PASSWORD="" etc/scripts/stage_docker.sh --install-ghc --test
|
||||
- docker build -t "${DEPLOYMENT_IMAGE}" etc/docker
|
||||
- docker login -u gitlab-ci-token -p "${CI_BUILD_TOKEN}" "${CI_REGISTRY}"
|
||||
- docker push "${DEPLOYMENT_IMAGE}"
|
||||
- |
|
||||
if [[ "$CI_BUILD_REF_NAME" == "master" ]]; then
|
||||
docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:latest"
|
||||
docker push "${CI_REGISTRY_IMAGE}:latest"
|
||||
fi
|
||||
if [[ "$CI_BUILD_REF_NAME" == "ci-cron" ]]; then
|
||||
docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:ci-cron"
|
||||
docker push "${CI_REGISTRY_IMAGE}:ci-cron"
|
||||
fi
|
||||
|
||||
deploy_prod:
|
||||
stage: deploy
|
||||
only:
|
||||
- master
|
||||
# when: manual
|
||||
environment:
|
||||
name: production
|
||||
url: https://www.stackage.org/
|
||||
variables:
|
||||
CRON_DEPLOYMENT_NAME: "stackage-server-cron-prod"
|
||||
DEPLOYMENT_NAME: "stackage-server-prod"
|
||||
HOOGLE_DEPLOYMENT_NAME: "stackage-server-hoogle-prod"
|
||||
KUBE_NAMESPACE: "${PROD_KUBE_NAMESPACE}"
|
||||
PROD_DEPLOYMENT_IMAGE: "fpco/stackage-server-prod:${CI_BUILD_REF_SLUG}_${CI_PIPELINE_ID}"
|
||||
script:
|
||||
- mkdir -p /etc/deploy
|
||||
- echo "${KUBECONFIG_YAML}" > /etc/deploy/kubeconfig.enc
|
||||
- base64 -d </etc/deploy/kubeconfig.enc > ${KUBECONFIG}
|
||||
- kubectl set image "deployment/stackage-server-prod" stackage-server="$DEPLOYMENT_IMAGE"
|
||||
- kubectl set image "deployment/stackage-server-cron-prod" stackage-server-cron="$DEPLOYMENT_IMAGE"
|
||||
- kubectl set image "deployment/stackage-server-hoogle-prod" stackage-server-hoogle="$DEPLOYMENT_IMAGE"
|
||||
- kubectl rollout status "deployment/stackage-server-prod"
|
||||
- kubectl rollout status "deployment/stackage-server-hoogle-prod"
|
||||
- kubectl rollout status "deployment/stackage-server-cron-prod"
|
||||
5
etc/base-build/Dockerfile
Normal file
5
etc/base-build/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
FROM fpco/stack-build:lts-15.5
|
||||
|
||||
RUN stack update
|
||||
COPY stack.yaml stackage-server.cabal /src/
|
||||
RUN stack build --only-snapshot --stack-yaml /src/stack.yaml
|
||||
6
etc/base-run/Dockerfile
Normal file
6
etc/base-run/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
||||
FROM fpco/stack-run@sha256:4b170ac899755a89c0295b7726c5530015211055125f6e3f6c5b902cb3e9b74b
|
||||
|
||||
RUN export DEBIAN_FRONTEND=noninteractive && \
|
||||
apt-get update && \
|
||||
wget -qO- https://get.haskellstack.org/ | sh -x && \
|
||||
unset DEBIAN_FRONTEND
|
||||
@ -1,6 +1,4 @@
|
||||
resolver: nightly-2020-02-08
|
||||
packages:
|
||||
- '.'
|
||||
resolver: lts-15.6
|
||||
extra-deps:
|
||||
- barrier-0.1.1@sha256:2021f84c3aba67bb635d72825d3bc0371942444dc014bc307b875071e29eea98,3931
|
||||
- hackage-security-0.6.0.0@sha256:69987d46e7b55fe5f0fc537021c3873c5f6f44a6665d349ee6995fd593df8147,11976
|
||||
|
||||
Loading…
Reference in New Issue
Block a user