Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c00b92

Browse files
committed
chore: Reduce deployment times by excluding Docker images (#1945)
* chore: Reduce deployment times by excluding Docker images Only the Windows and Linux binaries are build during deploy, so we can save many minutes by excluding Docker images. * Stop docker image builds on snapshot * Fix artifact upload * Skip typecheck for release * Flag deploy
1 parent df3201c commit 0c00b92

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

.github/workflows/coder.yaml

+13-17
Original file line numberDiff line numberDiff line change
@@ -355,21 +355,21 @@ jobs:
355355
path: ${{ steps.go-cache-paths.outputs.go-mod }}
356356
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
357357

358-
- uses: goreleaser/goreleaser-action@v3
359-
with:
360-
install-only: true
361-
362358
- name: Cache Node
363359
id: cache-node
364360
uses: actions/cache@v3
365361
with:
366362
path: |
367363
**/node_modules
368364
.eslintcache
369-
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
365+
key: js-${{ runner.os }}-release-node-${{ hashFiles('**/yarn.lock') }}
370366
restore-keys: |
371367
js-${{ runner.os }}-
372368
369+
- uses: goreleaser/goreleaser-action@v3
370+
with:
371+
install-only: true
372+
373373
- name: Build site
374374
run: make -B site/out/index.html
375375

@@ -379,18 +379,6 @@ jobs:
379379
version: latest
380380
args: release --snapshot --rm-dist --skip-sign
381381

382-
- uses: actions/upload-artifact@v3
383-
with:
384-
name: coder_windows_amd64.zip
385-
path: ./dist/coder_*_windows_amd64.zip
386-
retention-days: 7
387-
388-
- uses: actions/upload-artifact@v3
389-
with:
390-
name: coder_linux_amd64.tar.gz
391-
path: ./dist/coder_*_linux_amd64.tar.gz
392-
retention-days: 7
393-
394382
- name: Install Release
395383
run: |
396384
gcloud config set project coder-dogfood
@@ -402,6 +390,14 @@ jobs:
402390
- name: Start
403391
run: gcloud compute ssh coder -- sudo service coder restart
404392

393+
- uses: actions/upload-artifact@v3
394+
with:
395+
name: coder
396+
path: |
397+
./dist/coder_*_linux_amd64.tar.gz
398+
./dist/coder_*_windows_amd64.zip
399+
retention-days: 7
400+
405401
test-js:
406402
name: "test/js"
407403
runs-on: ubuntu-latest

.goreleaser.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ nfpms:
9494
- src: coder.service
9595
dst: /usr/lib/systemd/system/coder.service
9696

97+
# Image templates are empty on snapshots to avoid lengthy builds for development.
9798
dockers:
98-
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-amd64"]
99+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-amd64{{ end }}"]
99100
id: coder-linux
100101
dockerfile: Dockerfile
101102
use: buildx
@@ -108,7 +109,7 @@ dockers:
108109
- --label=org.opencontainers.image.version={{ .Version }}
109110
- --label=org.opencontainers.image.revision={{ .FullCommit }}
110111
- --label=org.opencontainers.image.licenses=AGPL-3.0
111-
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-arm64"]
112+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-arm64{{ end }}"]
112113
goarch: arm64
113114
dockerfile: Dockerfile
114115
use: buildx
@@ -121,7 +122,7 @@ dockers:
121122
- --label=org.opencontainers.image.version={{ .Tag }}
122123
- --label=org.opencontainers.image.revision={{ .FullCommit }}
123124
- --label=org.opencontainers.image.licenses=AGPL-3.0
124-
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-armv7"]
125+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-armv7{{ end }}"]
125126
goarch: arm
126127
goarm: "7"
127128
dockerfile: Dockerfile

site/webpack.common.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const dashboardHTMLPluginConfig = new HtmlWebpackPlugin({
3838
template: path.join(templatePath, "index.html"),
3939
})
4040

41-
export const commonWebpackConfig: Configuration = {
41+
export const createCommonWebpackConfig = (options?: { skipTypecheck: boolean }): Configuration => ({
4242
// entry defines each "page" or "chunk". In v1, we have two "pages":
4343
// dashboard and terminal. This is desired because the terminal has the xterm
4444
// vendor, and it is undesireable to load all of xterm on a dashboard
@@ -78,6 +78,7 @@ export const commonWebpackConfig: Configuration = {
7878
loader: "ts-loader",
7979
options: {
8080
configFile: "tsconfig.prod.json",
81+
transpileOnly: options?.skipTypecheck,
8182
},
8283
},
8384
],
@@ -106,4 +107,4 @@ export const commonWebpackConfig: Configuration = {
106107

107108
// plugins customize the build process
108109
plugins: [environmentPlugin, dashboardHTMLPluginConfig],
109-
}
110+
})

site/webpack.dev.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin"
66
import { Configuration } from "webpack"
77
import "webpack-dev-server"
8-
import { commonWebpackConfig } from "./webpack.common"
8+
import { createCommonWebpackConfig } from "./webpack.common"
9+
10+
const commonWebpackConfig = createCommonWebpackConfig()
911

1012
const commonPlugins = commonWebpackConfig.plugins || []
1113

1214
const commonRules = commonWebpackConfig.module?.rules || []
1315

1416
const config: Configuration = {
15-
...commonWebpackConfig,
17+
...createCommonWebpackConfig,
1618

1719
// devtool controls how source maps are generated. In development, we want
1820
// more details (less optimized) for more readability and an easier time

site/webpack.prod.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import CopyWebpackPlugin from "copy-webpack-plugin"
66
import CSSMinimizerPlugin from "css-minimizer-webpack-plugin"
77
import MiniCSSExtractPlugin from "mini-css-extract-plugin"
88
import { Configuration } from "webpack"
9-
import { commonWebpackConfig } from "./webpack.common"
9+
import { createCommonWebpackConfig } from "./webpack.common"
10+
11+
const commonWebpackConfig = createCommonWebpackConfig({
12+
// This decreases compilation time when publishing releases.
13+
// The "test/js" step will already catch any TypeScript compilation errors.
14+
skipTypecheck: true,
15+
})
1016

1117
const commonPlugins = commonWebpackConfig.plugins || []
1218

0 commit comments

Comments
 (0)