Skip to content

Commit ac6839d

Browse files
author
vtm9
committed
Move to elixir releases
1 parent 565705f commit ac6839d

16 files changed

Lines changed: 81 additions & 99 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- master
77
jobs:
88
build:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-18.04
1010

1111
services:
1212
db:
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
build:
99
if: github.repository == 'hexlet-codebattle/codebattle'
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-18.04
1111

1212
services:
1313
db:
@@ -98,14 +98,22 @@ jobs:
9898
file: ./services/app/cover/excoveralls.json
9999
fail_ci_if_error: true
100100

101-
- name: Pull dockers
102-
run: mix dockers.pull
103-
working-directory: ./services/app
104-
env:
105-
MIX_ENV: test
101+
- run: make release
106102

107-
- name: Run code checkers tests
108-
run: make test-code-checkers
109-
env:
110-
MIX_ENV: test
103+
- name: Login to Docker Hub
104+
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
105+
106+
- run: docker-build-app
107+
- run: docker-push-app
108+
109+
# - name: Pull dockers
110+
# run: mix dockers.pull
111+
# working-directory: ./services/app
112+
# env:
113+
# MIX_ENV: test
114+
115+
# - name: Run code checkers tests
116+
# run: make test-code-checkers
117+
# env:
118+
# MIX_ENV: test
111119

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@ ansible-edit-secrets:
3030

3131
ansible-vault-edit-production:
3232
docker run -v $(CURDIR):/app -it -w /app williamyeh/ansible:ubuntu18.04 ansible-vault edit --vault-password-file tmp/ansible-vault-password ansible/production/group_vars/all/vault.yml
33+
34+
release:
35+
make -C services/app release
36+
37+
docker-build-app:
38+
docker build --cache-from=codebattle/app --tag codebattle/app --file services/app/Dockerfile.rel services/app
39+
40+
docker-push-app:
41+
docker push codebattle/app:latest

k8s/Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,33 @@ PWD:=$(shell pwd)
22

33
kb-%: export KUBECONFIG=$(PWD)/kubeconfig.yml
44
helm-%: export KUBECONFIG=$(PWD)/kubeconfig.yml
5+
kb-app-%: POD_NAME = $(shell kubectl get pod -l "app.kubernetes.io/instance=app" -o name --kubeconfig=$(KUBECONFIG))
56

67
kb-get-pods:
78
kubectl get pod -w -o wide
89

910
kb-get-nodes:
1011
kubectl get nodes
1112

12-
helm-init:
13-
helm install --name app $(PWD)/app-chart
13+
helm-init: helm-add-repos helm-install-ingress helm-install-app helm-install-keel
14+
15+
helm-add-repos:
16+
helm repo add stable https://kubernetes-charts.storage.googleapis.com
17+
helm repo add keel https://charts.keel.sh
18+
19+
helm-install-app:
20+
helm install app $(PWD)/app-chart
1421

1522
helm-upgrade-app:
1623
helm upgrade app $(PWD)/app-chart
1724

1825
helm-install-ingress:
19-
helm install stable/nginx-ingress --name ingress --set rbac.create=true
26+
helm repo update
27+
helm install ingress stable/nginx-ingress
2028

2129
helm-install-keel:
22-
helm repo add keel https://charts.keel.sh
2330
helm repo update
24-
helm upgrade --install keel --namespace keel keel/keel
25-
26-
kb-app-%: POD_NAME = $(shell kubectl get pod -l "app.kubernetes.io/instance=app" -o name --kubeconfig=$(KUBECONFIG))
31+
helm upgrade --install keel --namespace=kube-system keel/keel
2732

2833
kb-app-tailf:
2934
kubectl logs -f $(POD_NAME) -c app

k8s/app-chart/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,7 @@ spec:
8080
env:
8181
- name: CODEBATTLE_VERSION
8282
value: {{ .Values.version }}
83+
- name: CODEBATTLE_PORT
84+
value: "4000"
8385
- name: DEPLOYED_AT
8486
value: "{{ now }}"

services/app/.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
_build
21
deps
32
node_modules
43
priv/static

services/app/Dockerfile.dev

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
FROM elixir:1.10.1
22

3-
# Install hex (Elixir package manager)
4-
# Install rebar (Erlang build tool)
53
RUN mix local.hex --force \
64
&& mix local.rebar --force
75

8-
# RUN mix archive.install --force https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez
9-
106
RUN mix local.rebar --force
117

128
RUN apt-get update \

services/app/Dockerfile.prod

Lines changed: 0 additions & 46 deletions
This file was deleted.

services/app/Dockerfile.rel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ubuntu:18.04
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update \
6+
&& apt-get install -y inotify-tools vim curl postgresql-client make
7+
8+
ENV DOCKER_CHANNEL edge
9+
ENV DOCKER_VERSION 19.03.5
10+
RUN curl -fsSL "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz" \
11+
| tar -xzC /usr/local/bin --strip=1 docker/docker
12+
13+
COPY _build/prod/rel/codebattle .
14+
COPY Makefile Makefile
15+
CMD exec /app/bin/codebattle start

services/app/Makefile

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
.PHONY: test tarball
1+
.PHONY: test release test-code-checkers
22

33
CACHE_MANIFEST := priv/static/cache_manifest.json
4-
RELEASE := _build/prod/rel/codebattle
5-
RELEASE_TARBALL := release.tar.gz
64
WEBPACK := ./node_modules/webpack/bin/webpack.js
75

86
default: format lint-js-fix credo test
@@ -24,13 +22,8 @@ lint-js-fix:
2422
yarn lint --fix
2523

2624
start:
27-
mix ecto.migrate
28-
mix phx.server
29-
30-
update:
31-
mix deps.update --all
32-
ncu -u
33-
npm update
25+
bin/codebattle eval "Codebattle.Utils.Release.migrate"
26+
bin/codebattle start
3427

3528
console:
3629
iex -S mix
@@ -42,12 +35,7 @@ test-code-checkers: export CODEBATTLE_RUN_CODE_CHECK = true
4235
test-code-checkers:
4336
mix test test/code_check --max-failures 1
4437

45-
tarball: $(RELEASE_TARBALL)
46-
47-
$(RELEASE_TARBALL): build-release
48-
tar czf $(RELEASE_TARBALL) $(RELEASE)
49-
50-
build-release: $(CACHE_MANIFEST)
38+
release: $(CACHE_MANIFEST)
5139
MIX_ENV=prod mix release --overwrite
5240

5341
$(CACHE_MANIFEST): build-assets
@@ -58,3 +46,7 @@ build-assets: $(WEBPACK)
5846

5947
$(WEBPACK):
6048
yarn install --frozen-lockfile
49+
50+
build-and-push-base:
51+
docker build -t codebattle/base --file Dockerfile.base .
52+
docker push codebattle/base:latest

0 commit comments

Comments
 (0)