Skip to content

Commit 1dfeccc

Browse files
Improving Build (#150)
1 parent 97d3546 commit 1dfeccc

File tree

11 files changed

+79
-202
lines changed

11 files changed

+79
-202
lines changed

.github/workflows/deploy.production.yml

Lines changed: 9 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -21,96 +21,33 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: ⬇️ Checkout repo
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525

2626
- name: ⎔ Setup node
27-
uses: actions/setup-node@v3
27+
uses: actions/setup-node@v4
2828
with:
29-
node-version: 16
29+
node-version: 20
3030

3131
- name: 📥 Install deps
3232
uses: bahmutov/npm-install@v1
3333

3434
- name: ⚡ Run vitest
3535
run: npm run test -- --coverage
3636

37-
build:
38-
if: github.repository == 'remix-run/remix-website'
39-
name: 🐳 Build
40-
runs-on: ubuntu-latest
41-
steps:
42-
- name: ⬇️ Checkout repo
43-
uses: actions/checkout@v3
44-
45-
- name: 👀 Read app name
46-
uses: SebRollen/[email protected]
47-
id: app_name
48-
with:
49-
file: "fly.production.toml"
50-
field: "app"
51-
52-
- name: 🐳 Set up Docker Buildx
53-
uses: docker/setup-buildx-action@v2
54-
55-
# Setup cache
56-
- name: ⚡️ Cache Docker layers
57-
uses: actions/cache@v3
58-
with:
59-
path: /tmp/.buildx-cache
60-
key: ${{ runner.os }}-buildx-${{ github.sha }}
61-
restore-keys: |
62-
${{ runner.os }}-buildx-
63-
- name: 🔑 Fly Registry Auth
64-
uses: docker/login-action@v2
65-
with:
66-
registry: registry.fly.io
67-
username: x
68-
password: ${{ secrets.FLY_API_TOKEN }}
69-
70-
- name: 🐳 Docker build
71-
uses: docker/build-push-action@v4
72-
with:
73-
context: .
74-
push: true
75-
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
76-
build-args: |
77-
COMMIT_SHA=${{ github.sha }}
78-
cache-from: type=local,src=/tmp/.buildx-cache
79-
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
80-
81-
# This ugly bit is necessary if you don't want your cache to grow forever
82-
# till it hits GitHub's limit of 5GB.
83-
# Temp fix
84-
# https://github.com/docker/build-push-action/issues/252
85-
# https://github.com/moby/buildkit/issues/1896
86-
- name: 🚚 Move cache
87-
run: |
88-
rm -rf /tmp/.buildx-cache
89-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
9037
deploy:
9138
name: 🚀 Deploy
9239
runs-on: ubuntu-latest
93-
needs: [test, build]
40+
needs: [test]
9441
steps:
9542
- name: ⬇️ Checkout repo
96-
uses: actions/checkout@v3
97-
98-
- name: 👀 Read app name
99-
uses: SebRollen/[email protected]
100-
id: app_name
101-
with:
102-
file: "fly.production.toml"
103-
field: "app"
43+
uses: actions/checkout@v4
44+
45+
- name: 🎈 Setup Fly
46+
uses: superfly/flyctl-actions/[email protected]
10447

10548
- name: 🚀 Deploy Production
10649
if: ${{ github.ref == 'refs/heads/main' }}
107-
uses: superfly/[email protected]
108-
with:
109-
args: |
110-
deploy --config ./fly.production.toml \
111-
--build-arg SOURCE_REPO="remix-run/remix" \
112-
--build-arg RELEASE_PACKAGE="remix" \
113-
--strategy rolling
50+
run: flyctl deploy --remote-only --config ./fly.production.toml --build-arg SOURCE_REPO="remix-run/remix" --build-arg RELEASE_PACKAGE="remix" --strategy rolling
11451
env:
11552
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
11653

.github/workflows/deploy.staging.yml

Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -23,94 +23,31 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: ⬇️ Checkout repo
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2727

2828
- name: ⎔ Setup node
29-
uses: actions/setup-node@v3
29+
uses: actions/setup-node@v4
3030
with:
31-
node-version: 16
31+
node-version: 20
3232

3333
- name: 📥 Install deps
3434
uses: bahmutov/npm-install@v1
3535

3636
- name: ⚡ Run vitest
3737
run: npm run test -- --coverage
3838

39-
build:
40-
if: github.repository == 'remix-run/remix-website'
41-
name: 🐳 Build
42-
runs-on: ubuntu-latest
43-
steps:
44-
- name: ⬇️ Checkout repo
45-
uses: actions/checkout@v3
46-
47-
- name: 👀 Read app name
48-
uses: SebRollen/[email protected]
49-
id: app_name
50-
with:
51-
file: "fly.staging.toml"
52-
field: "app"
53-
54-
- name: 🐳 Set up Docker Buildx
55-
uses: docker/setup-buildx-action@v2
56-
57-
# Setup cache
58-
- name: ⚡️ Cache Docker layers
59-
uses: actions/cache@v3
60-
with:
61-
path: /tmp/.buildx-cache
62-
key: ${{ runner.os }}-buildx-${{ github.sha }}
63-
restore-keys: |
64-
${{ runner.os }}-buildx-
65-
- name: 🔑 Fly Registry Auth
66-
uses: docker/login-action@v2
67-
with:
68-
registry: registry.fly.io
69-
username: x
70-
password: ${{ secrets.FLY_API_TOKEN }}
71-
72-
- name: 🐳 Docker build
73-
uses: docker/build-push-action@v4
74-
with:
75-
context: .
76-
push: true
77-
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
78-
build-args: |
79-
COMMIT_SHA=${{ github.sha }}
80-
cache-from: type=local,src=/tmp/.buildx-cache
81-
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
82-
83-
# This ugly bit is necessary if you don't want your cache to grow forever
84-
# till it hits GitHub's limit of 5GB.
85-
# Temp fix
86-
# https://github.com/docker/build-push-action/issues/252
87-
# https://github.com/moby/buildkit/issues/1896
88-
- name: 🚚 Move cache
89-
run: |
90-
rm -rf /tmp/.buildx-cache
91-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
9239
deploy:
9340
name: 🚀 Deploy
9441
runs-on: ubuntu-latest
95-
needs: [test, build]
42+
needs: [test]
9643
steps:
9744
- name: ⬇️ Checkout repo
98-
uses: actions/checkout@v3
99-
100-
- name: 👀 Read app name
101-
uses: SebRollen/[email protected]
102-
id: app_name
103-
with:
104-
file: "fly.staging.toml"
105-
field: "app"
45+
uses: actions/checkout@v4
46+
47+
- name: 🎈 Setup Fly
48+
uses: superfly/flyctl-actions/[email protected]
10649

10750
- name: 🚀 Deploy Staging
108-
uses: superfly/[email protected]
109-
with:
110-
args: |
111-
deploy --config ./fly.staging.toml \
112-
--build-arg SOURCE_REPO="remix-run/remix" \
113-
--build-arg RELEASE_PACKAGE="remix" \
114-
--strategy bluegreen
51+
run: flyctl deploy --remote-only --config ./fly.staging.toml --build-arg SOURCE_REPO="remix-run/remix" --build-arg RELEASE_PACKAGE="remix" --strategy bluegreen
11552
env:
116-
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
53+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

.github/workflows/format.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ jobs:
1616

1717
steps:
1818
- name: ⬇️ Checkout repo
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020
with:
2121
token: ${{ secrets.FORMAT_PAT }}
2222

2323
- name: ⎔ Setup node
24-
uses: actions/setup-node@v3
24+
uses: actions/setup-node@v4
2525
with:
26-
node-version: 16
26+
node-version: 20
2727

2828
- name: 📥 Install deps
2929
uses: bahmutov/npm-install@v1

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: ⬇️ Checkout repo
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121

2222
- name: ⎔ Setup node
23-
uses: actions/setup-node@v3
23+
uses: actions/setup-node@v4
2424
with:
25-
node-version: 16
25+
node-version: 20
2626

2727
- name: 📥 Install deps
2828
uses: bahmutov/npm-install@v1

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: ⬇️ Checkout repo
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919

2020
- name: ⎔ Setup node
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
2222
with:
23-
node-version: 16
23+
node-version: 20
2424

2525
- name: 📥 Install deps
2626
uses: bahmutov/npm-install@v1

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
20

Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# base node image
2-
FROM node:18-bullseye-slim as base
2+
FROM node:20-bullseye-slim as base
33

44
# set for base and all layer that inherit from it
55
ENV NODE_ENV production
@@ -15,17 +15,17 @@ FROM base as deps
1515

1616
WORKDIR /remixapp
1717

18-
ADD package.json package-lock.json .npmrc ./
19-
RUN npm install --production=false
18+
ADD package.json package-lock.json ./
19+
RUN npm install --include=dev
2020

2121
# Setup production node_modules
2222
FROM base as production-deps
2323

2424
WORKDIR /remixapp
2525

2626
COPY --from=deps /remixapp/node_modules /remixapp/node_modules
27-
ADD package.json package-lock.json .npmrc ./
28-
RUN npm prune --production
27+
ADD package.json package-lock.json ./
28+
RUN npm prune --omit=dev
2929

3030
# Build the app
3131
FROM base as build
@@ -47,6 +47,9 @@ WORKDIR /remixapp
4747

4848
COPY --from=production-deps /remixapp/node_modules /remixapp/node_modules
4949
COPY --from=build /remixapp/build /remixapp/build
50-
ADD . .
50+
COPY --from=build /remixapp/public /remixapp/public
51+
COPY --from=build /remixapp/server.js /remixapp/server.js
52+
COPY --from=build /remixapp/package.json /remixapp/package.json
53+
COPY --from=build /remixapp/start.sh /remixapp/start.sh
5154

5255
CMD ["npm", "start"]

0 commit comments

Comments
 (0)