Add Dockerfile and staging deployment setup

This commit is contained in:
Rob Watson 2021-11-27 14:26:14 +01:00
parent 817a10d269
commit e1a15a5e69
5 changed files with 63 additions and 3 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
/frontend/node_modules

35
Dockerfile Normal file
View File

@ -0,0 +1,35 @@
FROM node:14-alpine3.14 AS node-builder
RUN apk --no-cache --virtual build-dependencies add \
g++ \
make
WORKDIR /app
COPY frontend/ .
ARG API_URL
ENV REACT_APP_API_URL=$API_URL
RUN yarn install
RUN yarn build
FROM golang:1.17.3-alpine3.14 as go-builder
ENV GOPATH ""
RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
WORKDIR /app
ADD backend/go.mod backend/go.sum ./
RUN go mod download
ADD backend/ .
RUN go build -o ./clipper ./cmd/clipper/
FROM alpine:3.14
RUN apk add ffmpeg
COPY backend/sql/migrations /app/migrations
COPY --from=go-builder /app/clipper /bin/clipper
COPY --from=go-builder /root/go/bin/migrate /bin/migrate
COPY --from=node-builder /app/build /app/assets
ENV ASSETS_HTTP_BASE_PATH "/app/assets"
ENTRYPOINT ["/bin/clipper"]

23
deploy.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
#
# Build and deploy Clipper.
#
# Dependencies:
#
# docker
# pv (pacman -S pv)
# bzip2
#
# To run migrations from container:
#
# docker-compose run --no-deps --entrypoint /bin/sh clipper-staging -c '/bin/migrate -path /app/migrations -database $DATABASE_URL up'
#
# TODO: production build
set -ex
docker build \
-t netfluxio/clipper-staging:latest \
--build-arg API_URL=https://clipper-staging.netflux.io \
.
docker save netfluxio/clipper-staging:latest | bzip2 | pv | ssh netflux 'bunzip2 | docker load'

1
frontend/.env Normal file
View File

@ -0,0 +1 @@
REACT_APP_API_URL=http://localhost:8888

View File

@ -20,6 +20,8 @@ const thumbnailHeight = 100;
const initialViewportSeconds = 10; const initialViewportSeconds = 10;
const apiURL = process.env.REACT_APP_API_URL || 'http://localhost:8888';
// Frames represents a selection of audio frames. // Frames represents a selection of audio frames.
export interface Frames { export interface Frames {
start: number; start: number;
@ -212,8 +214,6 @@ function millisFromDuration(dur?: Duration): number {
return Math.floor(dur.seconds * 1000.0 + dur.nanos / 1000.0 / 1000.0); return Math.floor(dur.seconds * 1000.0 + dur.nanos / 1000.0 / 1000.0);
} }
const grpcHost = 'http://localhost:8888';
export function newRPC(): GrpcWebImpl { export function newRPC(): GrpcWebImpl {
return new GrpcWebImpl(grpcHost, {}); return new GrpcWebImpl(apiURL, {});
} }