Getting things ready for deploy to Heroku

This commit is contained in:
Radon Rosborough 2020-06-09 15:17:46 -06:00
parent f9e183e58e
commit 6295e51d90
9 changed files with 66 additions and 9 deletions

21
.circleci/config.yml Normal file
View File

@ -0,0 +1,21 @@
version: 2
jobs:
build_and_deploy:
docker:
- image: docker:18.09
steps:
- checkout
- setup_remote_docker
- run: apk add --no-cache --no-progress bash curl make
- run: curl https://cli-assets.heroku.com/install.sh | sh
- run: make deploy
workflows:
version: 2
ci:
jobs:
- build_and_deploy:
filters:
branches:
only: master
tags:
ignore: /.*/

1
.dockerignore Symbolic link
View File

@ -0,0 +1 @@
.gitignore

21
Dockerfile.prod Normal file
View File

@ -0,0 +1,21 @@
FROM ubuntu:focal
ARG UID
COPY scripts/docker-install.bash /tmp/
RUN /tmp/docker-install.bash "$UID"
USER $UID
WORKDIR /home/docker
EXPOSE 6119
ENTRYPOINT ["/usr/local/bin/pid1.bash"]
COPY scripts/pid1.bash /usr/local/bin/
RUN sudo deluser docker sudo
ADD --chown=docker:docker . /home/docker/src
WORKDIR src
RUN yarn install
RUN yarn run backend
RUN yarn run frontend
CMD yarn run server

View File

@ -8,7 +8,21 @@ help: ## Show this message
sed 's/:[^#]*[#]# /|/' | \
column -t -s'|' >&2
.PHONY: image
image-dev: ## Build Docker image for development
scripts/docker.bash build . -f Dockerfile.dev -t riju --build-arg "UID=$(UID)"
.PHONY: image
image-prod: ## Build Docker image for production
scripts/docker.bash build . -f Dockerfile.prod -t riju:prod --build-arg "UID=$(UID)"
.PHONY: docker
docker: ## Run shell with source code and deps inside Docker
scripts/docker.bash build . -t riju --build-arg "UID=$(UID)"
scripts/docker.bash run -it --rm -v "$(PWD):/home/docker/src" -p 6119:6119 riju
docker: image-dev ## Run shell with source code and deps inside Docker
scripts/docker.bash run -it --rm -v "$(PWD):/home/docker/src" -p 6119:6119 riju bash
.PHONY: deploy
deploy: image-prod ## Deploy to Heroku
scripts/docker.bash tag riju:prod registry.heroku.com/riju-sandbox/web
heroku auth:token | scripts/docker.bash login --username=_ --password-stdin registry.heroku.com
scripts/docker.bash push registry.heroku.com/riju-sandbox/web
heroku container:release web -a riju-sandbox

View File

@ -149,7 +149,7 @@ int main() {
monacoLang: "bat",
repl: "wine cmd",
main: "main.bat",
run: `pkill wineserver64; while pgrep wineserver64 >/dev/null; do sleep 0.05; done; wine cmd /k main.bat`,
run: `wine cmd /k main.bat`,
template: `echo "Hello, world!"
`,
},

View File

@ -6,8 +6,8 @@
<link rel="stylesheet" href="/css/index.css" />
</head>
<body>
<h1>Riju: online access to any programming language</h1>
<i>Select a language to get started immediately:</i>
<h1>Riju: online playground for every programming language</h1>
<i>Pick your favorite language to get started:</i>
<div class="grid">
<% for (const [id, {name}] of Object.entries(langs)) { %>
<a href=<%= "/" + encodeURIComponent(id) %> class="language">

View File

@ -32,7 +32,7 @@
"backend-dev": "tsc --watch",
"frontend": "webpack --production",
"frontend-dev": "webpack --development --watch",
"server": "node server.js",
"server": "node backend/out/server.js",
"server-dev": "watchexec -w backend/out -r -n node backend/out/server.js"
}
}

View File

@ -9,8 +9,8 @@ export SHELL="$(which bash)"
export HOST=0.0.0.0
if [[ -d src ]]; then
cd src
if [[ -d /home/docker/src ]]; then
cd /home/docker/src
fi
exec "$@"