Skip to content

Commit

Permalink
Docker build + env fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bgentry committed Aug 26, 2024
1 parent 2cbdc3b commit 4f60fbc
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 22 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
.env.*
dist
Dockerfile
node_modules
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if [ -f .env.local ]; then
dotenv .env.local
fi
File renamed without changes.
18 changes: 3 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
# syntax=docker/dockerfile:1

# PATH_PREFIX for configuring the frontend's path prefix
ARG PATH_PREFIX="/"

FROM node:20-alpine AS build-ui
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
ENV NODE_ENV=production
COPY . .
ARG PATH_PREFIX
# The URL (potentially relative) of the riverui API server to use. Defaults to
# /api if unset:
ARG VITE_RIVER_API_BASE_URL

RUN CLEAN_PATH_PREFIX=$(echo $PATH_PREFIX | sed 's:/$::') && \
VITE_RIVER_API_BASE_URL=${VITE_RIVER_API_BASE_URL:-${CLEAN_PATH_PREFIX}/api} && \
export VITE_RIVER_API_BASE_URL && \
npx vite build --base=${PATH_PREFIX}
RUN npx vite build

# Build the Go binary, including embedded UI files:
FROM golang:1.22-alpine AS build-go
FROM golang:1.23-alpine AS build-go
WORKDIR /go/src/riverui

COPY go.mod go.sum ./
Expand All @@ -37,7 +27,5 @@ RUN go build -o /bin/riverui ./cmd/riverui

FROM alpine:3.19.1

ARG PATH_PREFIX
ENV PATH_PREFIX=${PATH_PREFIX}
COPY --from=build-go /bin/riverui /bin/riverui
CMD /bin/riverui -prefix=$PATH_PREFIX
CMD ["/bin/riverui"]
4 changes: 0 additions & 4 deletions cmd/riverui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"github.com/jackc/pgx/v5/pgxpool"
"github.com/joho/godotenv"
"github.com/rs/cors"
sloghttp "github.com/samber/slog-http"

Expand All @@ -26,9 +25,6 @@ var logger *slog.Logger //nolint:gochecknoglobals

func main() {
ctx := context.Background()
if err := godotenv.Load(); err != nil {
fmt.Printf("No .env file detected, using environment variables\n")
}

if os.Getenv("RIVER_DEBUG") == "1" || os.Getenv("RIVER_DEBUG") == "true" {
logger = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/google/uuid v1.6.0
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438
github.com/jackc/pgx/v5 v5.6.0
github.com/joho/godotenv v1.5.1
github.com/riverqueue/river v0.11.2
github.com/riverqueue/river/riverdriver v0.11.2
github.com/riverqueue/river/riverdriver/riverpgxv5 v0.11.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down

0 comments on commit 4f60fbc

Please sign in to comment.