about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-04-17 20:53:52 +0200
committerAlan Pearce2024-04-17 22:11:34 +0200
commit415f57f98600ce5574d20d9a8ba9e9688545869d (patch)
treeff64bc7e0e18b0df61bf023d775df0756d78df6d
parentb4334bc531694344b7ae767c9695f150e0745e38 (diff)
downloadwebsite-415f57f98600ce5574d20d9a8ba9e9688545869d.tar.lz
website-415f57f98600ce5574d20d9a8ba9e9688545869d.tar.zst
website-415f57f98600ce5574d20d9a8ba9e9688545869d.zip
configure docker build
-rw-r--r--.dockerignore178
-rw-r--r--Dockerfile48
2 files changed, 25 insertions, 201 deletions
diff --git a/.dockerignore b/.dockerignore
index f81d56e..359576c 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,169 +1,9 @@
-# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
-
-# Logs
-
-logs
-_.log
-npm-debug.log_
-yarn-debug.log*
-yarn-error.log*
-lerna-debug.log*
-.pnpm-debug.log*
-
-# Diagnostic reports (https://nodejs.org/api/report.html)
-
-report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
-
-# Runtime data
-
-pids
-_.pid
-_.seed
-\*.pid.lock
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-
-lib-cov
-
-# Coverage directory used by tools like istanbul
-
-coverage
-\*.lcov
-
-# nyc test coverage
-
-.nyc_output
-
-# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
-
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-
-bower_components
-
-# node-waf configuration
-
-.lock-wscript
-
-# Compiled binary addons (https://nodejs.org/api/addons.html)
-
-build/Release
-
-# Dependency directories
-
-node_modules/
-jspm_packages/
-
-# Snowpack dependency directory (https://snowpack.dev/)
-
-web_modules/
-
-# TypeScript cache
-
-\*.tsbuildinfo
-
-# Optional npm cache directory
-
-.npm
-
-# Optional eslint cache
-
-.eslintcache
-
-# Optional stylelint cache
-
-.stylelintcache
-
-# Microbundle cache
-
-.rpt2_cache/
-.rts2_cache_cjs/
-.rts2_cache_es/
-.rts2_cache_umd/
-
-# Optional REPL history
-
-.node_repl_history
-
-# Output of 'npm pack'
-
-\*.tgz
-
-# Yarn Integrity file
-
-.yarn-integrity
-
-# dotenv environment variable files
-
-.env
-.env.development.local
-.env.test.local
-.env.production.local
-.env.local
-
-# parcel-bundler cache (https://parceljs.org/)
-
-.cache
-.parcel-cache
-
-# Next.js build output
-
-.next
-out
-
-# Nuxt.js build / generate output
-
-.nuxt
-dist
-
-# Gatsby files
-
-.cache/
-
-# Comment in the public line in if your project uses Gatsby and not Next.js
-
-# https://nextjs.org/blog/next-9-1#public-directory-support
-
-# public
-
-# vuepress build output
-
-.vuepress/dist
-
-# vuepress v2.x temp and cache directory
-
-.temp
-.cache
-
-# Docusaurus cache and generated files
-
-.docusaurus
-
-# Serverless directories
-
-.serverless/
-
-# FuseBox cache
-
-.fusebox/
-
-# DynamoDB Local files
-
-.dynamodb/
-
-# TernJS port file
-
-.tern-port
-
-# Stores VSCode versions used for testing VSCode extensions
-
-.vscode-test
-
-# yarn v2
-
-.yarn/cache
-.yarn/unplugged
-.yarn/build-state.yml
-.yarn/install-state.gz
-.pnp.\*
+*
+!cmd
+!content
+!internal
+!static
+!templates
+!config.toml
+!go.mod
+!go.sum
diff --git a/Dockerfile b/Dockerfile
index 3d31306..90dd051 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,52 +1,36 @@
 # syntax = docker/dockerfile:1
 
-# Adjust BUN_VERSION as desired
-ARG BUN_VERSION=1.1.2
-FROM docker.io/oven/bun:${BUN_VERSION} as base
-
-LABEL fly_launch_runtime="Bun"
+ARG GO_VERSION=1.22.1
+FROM docker.io/library/golang:${GO_VERSION} as builder
 
 WORKDIR /app
 
-FROM base as install
-RUN mkdir -p /temp/dev
-COPY --link bun.lockb package.json /temp/dev/
-RUN cd /temp/dev && bun install --frozen-lockfile
-
-RUN mkdir -p /temp/prod
-COPY --link bun.lockb package.json /temp/prod/
-RUN cd /temp/prod && bun install --frozen-lockfile --production
+COPY --link go.mod .
+RUN go mod download
 
-FROM base as build
-COPY --from=install /temp/dev/node_modules node_modules
+COPY --link . .
 
-# Copy application code
-COPY --link config.toml config.toml
-COPY --link src src
-COPY --link bin bin
-COPY --link content content
-COPY --link templates templates
-COPY --link static static
+# RUN go vet ./...
+ENV ENV=production
+RUN go run ./cmd/build
 
-ENV NODE_ENV=production
-RUN bun run bin/build.ts
-RUN rm -fr node_modules
-COPY --from=install /temp/prod/node_modules node_modules
-RUN bun build src/index.ts --compile --minify --sourcemap --outfile server
+RUN cp -r static/.well-known static/* public
+ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0
+RUN go build ./cmd/server/
 
 # Final stage for app image
-FROM gcr.io/distroless/base-nossl
+FROM gcr.io/distroless/static
 
 WORKDIR /app
 
 # Copy built application
-COPY config.toml /app/
-COPY --from=build /app /app
-COPY --from=build /app/public /app/public
+COPY --link config.toml .
+COPY --from=builder /app/public public
+COPY --from=builder /app/server server
 
 # Start the server by default, this can be overwritten at runtime
 EXPOSE 3000
 EXPOSE 9091
 
-ENV NODE_ENV=production
+ENV ENV=production
 CMD [ "/app/server" ]