mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
chore: Add dockerfile for deployment (#180)
This just adds a very simple dockerfile for deploying `coderd` (and later `provisionerd`).
This adds a `deploy` directory at the root, and a `make docker/build` command to the makefile.
Thanks @jawnsy for the all the help 😄
This commit is contained in:
50
.github/workflows/coder.yaml
vendored
50
.github/workflows/coder.yaml
vendored
@ -88,14 +88,9 @@ jobs:
|
||||
- run: "make --output-sync -j gen"
|
||||
- run: ./scripts/check_unstaged.sh
|
||||
|
||||
style:
|
||||
name: "style/${{ matrix.style }}"
|
||||
style-fmt:
|
||||
name: "style/fmt"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
style:
|
||||
- fmt
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
@ -116,8 +111,8 @@ jobs:
|
||||
run: yarn install
|
||||
working-directory: site
|
||||
|
||||
- name: "make ${{ matrix.style }}"
|
||||
run: "make --output-sync -j ${{ matrix.style }}"
|
||||
- name: "make fmt"
|
||||
run: "make --output-sync -j fmt"
|
||||
|
||||
test-go:
|
||||
name: "test/go"
|
||||
@ -189,6 +184,43 @@ jobs:
|
||||
flags: unittest-go-${{ matrix.os }}
|
||||
fail_ci_if_error: true
|
||||
|
||||
deploy:
|
||||
name: "deploy"
|
||||
runs-on: ubuntu-latest
|
||||
#if: github.event_name == 'pull_request'
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Authenticate to Google Cloud
|
||||
uses: google-github-actions/auth@v0
|
||||
with:
|
||||
workload_identity_provider: projects/477254869654/locations/global/workloadIdentityPools/github/providers/github
|
||||
service_account: github@coder-ci.iam.gserviceaccount.com
|
||||
|
||||
- name: Set up Google Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0
|
||||
|
||||
- name: Configure Docker for Google Artifact Registry
|
||||
run: gcloud auth configure-docker us-docker.pkg.dev
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "14"
|
||||
|
||||
- run: yarn install
|
||||
working-directory: site
|
||||
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: "^1.17"
|
||||
|
||||
- run: make docker/image/coder
|
||||
|
||||
- run: docker push us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest
|
||||
|
||||
test-js:
|
||||
name: "test/js"
|
||||
runs-on: ubuntu-latest
|
||||
|
7
Makefile
7
Makefile
@ -3,7 +3,7 @@ bin/coderd:
|
||||
go build -o bin/coderd cmd/coderd/main.go
|
||||
.PHONY: bin/coderd
|
||||
|
||||
build: site/out bin/coderd
|
||||
build: site/out bin/coderd
|
||||
.PHONY: build
|
||||
|
||||
# Runs migrations to output a dump of the database.
|
||||
@ -17,6 +17,11 @@ database/generate: fmt/sql database/dump.sql database/query.sql
|
||||
cd database && gofmt -w -r 'Queries -> sqlQuerier' *.go
|
||||
.PHONY: database/generate
|
||||
|
||||
docker/image/coder: build
|
||||
cp ./images/coder/run.sh ./bin
|
||||
docker build --network=host -t us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest -f images/coder/Dockerfile ./bin
|
||||
.PHONY: docker/build
|
||||
|
||||
fmt/prettier:
|
||||
@echo "--- prettier"
|
||||
# Avoid writing files in CI to reduce file write activity
|
||||
|
13
images/coder/Dockerfile
Normal file
13
images/coder/Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM registry.access.redhat.com/ubi8/ubi:latest
|
||||
|
||||
COPY coderd /coder/coderd
|
||||
RUN chmod +x /coder/coderd
|
||||
|
||||
COPY run.sh /coder/run.sh
|
||||
RUN chmod +x /coder/run.sh
|
||||
|
||||
# Once `provisionerd` is available, we'll also need that binary
|
||||
# COPY bin/provisionerd /provisionerd
|
||||
# RUN chmod +x /provisionerd
|
||||
|
||||
ENTRYPOINT ["/coder/run.sh"]
|
30
images/coder/run.sh
Executable file
30
images/coder/run.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
EMAIL=${EMAIL:-admin@coder.com}
|
||||
USERNAME=${USERNAME:-admin}
|
||||
ORGANIZATION=${ORGANIZATION:-ACME-Corp}
|
||||
PASSWORD=${PASSWORD:-password}
|
||||
PORT=${PORT:-8000}
|
||||
|
||||
# Helper to create an initial user
|
||||
function create_initial_user() {
|
||||
# TODO: We need to wait for `coderd` to spin up -
|
||||
# need to replace with a deterministic strategy
|
||||
sleep 5s
|
||||
|
||||
curl -X POST \
|
||||
-d '{"email": "'"$EMAIL"'", "username": "'"$USERNAME"'", "organization": "'"$ORGANIZATION"'", "password": "'"$PASSWORD"'"}' \
|
||||
-H 'Content-Type:application/json' \
|
||||
"http://localhost:$PORT/api/v2/user"
|
||||
}
|
||||
|
||||
# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly
|
||||
# to kill both at the same time. For more details, see:
|
||||
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
|
||||
(
|
||||
trap 'kill 0' SIGINT
|
||||
create_initial_user &
|
||||
/coder/coderd --address=":$PORT"
|
||||
)
|
Reference in New Issue
Block a user