Move around Dockerfiles

This commit is contained in:
Michael Snoyman 2020-04-05 15:54:27 +03:00
parent 6afbf09892
commit ec23962208
No known key found for this signature in database
GPG Key ID: 907EAE2F42B52046
19 changed files with 9 additions and 517 deletions

View File

@ -1,21 +0,0 @@
jobs:
- job: ${{ parameters.name }}
timeoutInMinutes: 120
pool:
vmImage: ${{ parameters.vmImage }}
steps:
- script: |
set -ex
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
mkdir -p ~/.local/bin
curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
export PATH=$HOME/.local/bin:$PATH
sudo apt-get update
sudo apt-get install libpq-dev
stack test --interleaved-output
set +ex
env:
OS_NAME: ${{ parameters.os }}
displayName: Installation

View File

@ -1,18 +0,0 @@
# This is the complex Azure configuration, which is intended for use
# on open source libraries which need compatibility across multiple GHC
# versions, must work with cabal-install, and should be
# cross-platform. For more information and other options, see:
#
# https://docs.haskellstack.org/en/stable/azure_ci/
#
# Copy these contents into the root directory of your Github project in a file
# named azure-pipelines.yml
#
# For better organization, you split various jobs into seprate parts
# and each of them are controlled via individual file.
jobs:
- template: azure-linux-template.yml
parameters:
name: Linux
vmImage: ubuntu-16.04
os: linux

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
.git
.stack-work

View File

@ -18,13 +18,14 @@ jobs:
- 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 build . -f docker/Dockerfile.base-run --tag base-run
docker tag base-run $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 build . -f docker/Dockerfile.base-build --tag $IMAGE_ID
docker push $IMAGE_ID
echo Pushed new base build image $IMAGE_ID

View File

@ -16,7 +16,7 @@ jobs:
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Build image
run: docker build . --tag image
run: docker build . -f docker/Dockerfile.runtime --tag image
- name: Push to Docker Hub
run: |

View File

@ -1,7 +1,7 @@
stackage-server
===============
[![Build Status](https://dev.azure.com/fpco/stackage-server/_apis/build/status/fpco.stackage-server?branchName=master)](https://dev.azure.com/fpco/stackage-server/_build/latest?definitionId=1&branchName=master)
![Runtime image](https://github.com/fpco/stackage-server/workflows/Runtime%20image/badge.svg)
Server for stable, curated Haskell package sets

View File

@ -1,5 +1,6 @@
FROM fpco/stack-build:lts-15.5
FROM base-run
RUN stack update
COPY stack.yaml stackage-server.cabal /src/
RUN stack setup --stack-yaml /src/stack.yaml
RUN stack build --only-snapshot --stack-yaml /src/stack.yaml

View File

@ -1,61 +0,0 @@
# Kubernetes
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: "${CRON_DEPLOYMENT_NAME}"
spec:
replicas: 1
minReadySeconds: 5
strategy:
type: Recreate
template:
metadata:
labels:
app: "${CRON_DEPLOYMENT_APP}"
spec:
volumes:
- name: stackage-server-cron-volume
secret:
secretName: ${CRON_DEPLOYMENT_NAME}-secret
containers:
- name: stackage-server-cron
image: "${DEPLOYMENT_IMAGE}"
imagePullPolicy: Always
env:
- name: PGSTRING
valueFrom:
secretKeyRef:
name: "${DEPLOYMENT_NAME}"
key: PGCONN
command:
- bash
- "-c"
- |
set -eux
source /secret/aws.sh
mkdir -p /work
cd /work
while true
do
date
stack update
/usr/local/bin/stackage-server-cron
sleep 5m
done
resources:
# NOTE: This differs between prod and ci.
# Once we migrate to helm we'll be able to set it
# per environment.
requests:
cpu: 150m
memory: 2048Mi
limits:
cpu: 300m
memory: 4096Mi
volumeMounts:
- name: stackage-server-cron-volume
readOnly: true
mountPath: /secret
imagePullSecrets:
- name: registry-key

View File

@ -1,65 +0,0 @@
# Kubernetes
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: "${DEPLOYMENT_NAME}"
spec:
replicas: 2
minReadySeconds: 5
template:
metadata:
labels:
app: "${DEPLOYMENT_APP}"
spec:
containers:
- name: stackage-server
image: "${DEPLOYMENT_IMAGE}"
imagePullPolicy: Always
ports:
- name: http
containerPort: 3000
command: ["stackage-server"]
workingDir: /app
env:
- name: APPROOT
value: "${APPROOT}"
- name: PGSTRING
valueFrom:
secretKeyRef:
name: "${DEPLOYMENT_NAME}"
key: PGCONN
readinessProbe:
httpGet:
path: /
port: 3000
httpHeaders:
# Works around stackage-server's `forceSSL` redirect
- name: HTTPS
value: "on"
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 5
successThreshold: 1
livenessProbe:
httpGet:
path: /
port: 3000
httpHeaders:
# Works around stackage-server's `forceSSL` redirect
- name: HTTPS
value: "on"
initialDelaySeconds: 120
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
resources:
requests:
cpu: 100m
memory: 1.0Gi
limits:
cpu: 150m
memory: 1.5Gi
imagePullSecrets:
- name: registry-key

View File

@ -1,65 +0,0 @@
# Kubernetes
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: "${HOOGLE_DEPLOYMENT_NAME}"
spec:
replicas: 2
minReadySeconds: 5
template:
metadata:
labels:
app: "${HOOGLE_DEPLOYMENT_APP}"
spec:
containers:
- name: stackage-server-hoogle
image: "${DEPLOYMENT_IMAGE}"
imagePullPolicy: Always
ports:
- name: http
containerPort: 3000
command: ["stackage-server"]
workingDir: /app
env:
- name: APPROOT
value: "${APPROOT}"
- name: PGSTRING
valueFrom:
secretKeyRef:
name: "${DEPLOYMENT_NAME}"
key: PGCONN
readinessProbe:
httpGet:
path: /
port: 3000
httpHeaders:
# Works around stackage-server's `forceSSL` redirect
- name: HTTPS
value: "on"
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 5
successThreshold: 1
livenessProbe:
httpGet:
path: /
port: 3000
httpHeaders:
# Works around stackage-server's `forceSSL` redirect
- name: HTTPS
value: "on"
initialDelaySeconds: 120
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
resources:
requests:
cpu: 100m
memory: 1.0Gi
limits:
cpu: 150m
memory: 1.5Gi
imagePullSecrets:
- name: registry-key

View File

@ -1,19 +0,0 @@
# Kubernetes
---
apiVersion: v1
kind: Service
metadata:
name: "${HOOGLE_DEPLOYMENT_NAME}"
labels:
app: "${HOOGLE_DEPLOYMENT_APP}"
spec:
ports:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: http
type: ClusterIP
selector:
app: "${HOOGLE_DEPLOYMENT_APP}"

View File

@ -1,31 +0,0 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: "${DEPLOYMENT_NAME}"
labels:
app: "${DEPLOYMENT_APP}"
annotations:
kubernetes.io/ingress.class: "nginx"
kubernetes.io/tls-acme: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
rules:
- host: "${HOST}"
http:
paths:
- path: /haddock.*
backend:
serviceName: "${DEPLOYMENT_NAME}"
servicePort: 80
- path: /.+/hoogle
backend:
serviceName: "${HOOGLE_DEPLOYMENT_NAME}"
servicePort: 80
- backend:
serviceName: "${DEPLOYMENT_NAME}"
servicePort: 80
tls:
- hosts:
- "${HOST}"
secretName: "${DEPLOYMENT_NAME}-tls"

View File

@ -1,19 +0,0 @@
# Kubernetes
---
apiVersion: v1
kind: Service
metadata:
name: "${DEPLOYMENT_NAME}"
labels:
app: "${DEPLOYMENT_APP}"
spec:
ports:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: http
selector:
app: "${DEPLOYMENT_APP}"
type: ClusterIP

View File

@ -1,30 +0,0 @@
# `stackage-server` load tests
This directory can be used to test an on-premises instance of `stackage-server` for quality of service metrics. Follow the instructions below to run it.
We assume you will be using `pyenv` to handle different Python environments in a safe manner. If you prefer installing packages globally (not recommended), jump straight to the line commented with `# install dependencies`. Before doing anything, set an environment variable `STACKAGE_SERVER_REPO` on your shell to this repos root folder. Then copy everything and run:
```shell
cd ~
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
# add the following lines to your shell initialisation for permanent usage
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# create an environment for tests
pyenv install 3.6.3
pyenv virtualenv 3.6.3 stackage-server-py-3.6.3
cd "${STACKAGE_SERVER_REPO}/etc/load-testing"
pyenv local stackage-server-py-3.6.3
pyenv activate stackage-server-py-3.6.3 # should happen automatically on previous line, but just to be sure
# install dependencies
pip install -r requirements.txt
# execute load tests
locust --host="http://yourlocalinstance.domain"
```
Then navigate to [127.0.0.1:8089](http://127.0.0.1:8089), set the number of clients to simulate, spawn rate, start it and wait a few minutes for the results to stabilise. You can then download or analyse directly on Locusts UI.

View File

@ -1,159 +0,0 @@
from locust import HttpLocust, task, TaskSet
from random import randrange
def random_element(xs):
return xs[randrange(len(xs))]
def select_snapshot():
_snapshots = [
"lts",
"nightly",
"lts-9.10",
"lts-9.7",
"lts-9.6",
"lts-9.5",
"lts-8.8",
"nightly-2017-07-05",
"nightly-2017-05-30",
"nightly-2017-03-25",
"lts-7.20",
]
return random_element(_snapshots)
def select_package():
_packages = [
"accelerate",
"adjunctions",
"aeson",
"binary",
"both",
"extensible-effects",
"hamlet",
"hdocs",
"microlens",
"range",
"sort",
"text",
"universe"
]
return random_element(_packages)
def select_hoogle_query():
_hoogle_queries = [
"Ord",
"Eq",
"Num",
"pack",
"Text -> String",
"fmap",
"a -> a",
"traverse",
"bracket",
"^.",
">>>",
"<$>",
"bimap",
"inject"
]
return random_element(_hoogle_queries)
class HoogleQueries(TaskSet):
@task
def hoogle_queries(self):
_snapshot = select_snapshot()
_query = select_hoogle_query()
self.client.get("/" \
+ _snapshot \
+ "/hoogle?q=" + _query \
, name="/:snapshot/hoogle?q=[:query]")
@task
def stop(self):
self.interrupt()
class Haddock(TaskSet):
@task
def haddock(self):
_snapshot = select_snapshot()
_package = select_package()
self.client.get("/haddock/" \
+ _snapshot + "/" \
+ _package + "/" \
+ "doc-index-All.html" \
, name="/haddock/:snapshot/:package/doc-index-All.html")
@task
def stop(self):
self.interrupt()
class Documentation(TaskSet):
@task
def docs(self):
_snapshot = select_snapshot()
self.client.get("/" \
+ _snapshot \
+ "/docs" \
, name="/:snapshot/docs")
@task
def stop(self):
self.interrupt()
class PackageBrowser(TaskSet):
@task
def browse_package(self):
_snapshot = select_snapshot()
_package = select_package()
self.client.get("/" \
+ _snapshot \
+ "/package/" + _package \
, name="/:snapshot/package/:package")
@task
def stop(self):
self.interrupt()
class Snapshots(TaskSet):
@task
def updateSnapshots(self):
self.client.get("/download/snapshots.json")
@task
def stop(self):
self.interrupt()
class TopLevelPages(TaskSet):
@task(20)
def install(self):
self.client.get("/install")
@task(10)
def lts(self):
self.client.get("/lts")
@task(5)
def nightly(self):
self.client.get("/nightly")
@task(2)
def snapshots(self):
self.client.get("/snapshots")
@task(2)
def stop(self):
self.interrupt()
class UserBehaviour(TaskSet):
tasks = {
Haddock : 10,
HoogleQueries : 5,
PackageBrowser : 2,
Documentation : 2,
Snapshots : 1,
TopLevelPages : 1,
}
class WebsiteUser(HttpLocust):
task_set = UserBehaviour
min_wait = 1000
max_wait = 9000

View File

@ -1,17 +0,0 @@
certifi==2017.4.17
chardet==3.0.4
click==6.7
Flask==0.12.2
gevent==1.2.2
greenlet==0.4.12
idna==2.5
itsdangerous==0.24
Jinja2==2.9.6
-e git://github.com/locustio/locust.git@072d7752552ff32898253fcd5734c3b64995c17e#egg=locustio
MarkupSafe==1.0
msgpack-python==0.4.8
pyzmq==15.2.0
requests==2.18.1
six==1.10.0
urllib3==1.21.1
Werkzeug==0.12.2

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
set -ex
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
mkdir -p etc/docker/_artifacts
export LANG=C.UTF-8
stack install --local-bin-path=etc/docker/_artifacts "$@"
rsync -av --delete config static etc/docker/_artifacts/