Skip to content

Instantly share code, notes, and snippets.

@Kyu

Kyu/Dockerfile Secret

Created March 18, 2023 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kyu/57700056ec47f03affb02ad36b5de2d5 to your computer and use it in GitHub Desktop.
Save Kyu/57700056ec47f03affb02ad36b5de2d5 to your computer and use it in GitHub Desktop.
# Install dependencies only when needed
FROM node:16-apline AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY . .
RUN yarn set version berry
# If using npm with a `package-lock.json` comment out above and use below instead
# RUN npm ci
# Add `ARG` instructions below if you need `NEXT_PUBLIC_` variables
# then put the value on your fly.toml
# Example:
# ARG NEXT_PUBLIC_EXAMPLE="value here"
RUN yarn
# If using npm comment out above and use below instead
# RUN npm run build
# Production image, copy all the files and run next
# FROM node:16-alpine AS runner
# WORKDIR /app
# ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# RUN addgroup --system --gid 1001 nodejs
# RUN adduser --system --uid 1001 nextjs
# COPY --from=builder /app ./
RUN yarn install
RUN yarn build
RUN yarn web:prod
CMD ["yarn", "web:prod:serve", "-p", "8080"]
# If using npm comment out above and use below instead
# CMD ["npm", "run", "start"]
# https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
# https://stackoverflow.com/a/61892639/3875151
name: Fly Deploy NextJS
on:
push:
branches:
- main
# Pattern matched against refs/tags
tags:
- '**' # Push events to every tag including hierarchical tags like v1.0/beta
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# fly.toml file generated for queuepreview-frontend on 2023-03-05T15:13:49-06:00
app = "queuepreview-frontend"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
PORT = "8080"
[experimental]
auto_rollback = true
[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
po@pos-MacBook-Air:~/WebstormProjects/queuepreview|main ⇒ fly deploy --remote-only
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-holy-sun-5178 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 2.0s (0/1)
[+] Building 225.6s (13/13) FINISHED
=> [internal] load remote build context 0.0s
=> copy /context / 0.3s
=> [internal] load metadata for docker.io/library/node:16-alpine 0.1s
=> [1/9] FROM docker.io/library/node:16-alpine@sha256:fcb03294d3c0695cf9762dec94c0366f08e7a8c6a3c1e062d38c80ac30684d8a 0.0s
=> CACHED [2/9] RUN apk add --no-cache libc6-compat 0.0s
=> CACHED [3/9] WORKDIR /app 0.0s
=> [4/9] COPY . . 0.3s
=> [5/9] RUN yarn set version berry 1.6s
=> [6/9] RUN yarn 160.3s
=> [7/9] RUN yarn install 4.5s
=> [8/9] RUN yarn build 8.7s
=> [9/9] RUN yarn web:prod 34.9s
=> exporting to image 14.5s
=> => exporting layers 14.5s
=> => writing image sha256:1d121b864f0d80841b6f4b82c877cdca5d21f294f94f7a70fb0564d1fb7d3272 0.0s
=> => naming to registry.fly.io/queuepreview-frontend:deployment-01GVSS07G8ZVQTX6RZ8JH9B5W6 0.0s
--> Building image done
==> Pushing image to fly
The push refers to repository [registry.fly.io/queuepreview-frontend]
9c97be11c185: Preparing
5325078ca400: Preparing
02079c3c9ea3: Preparing
cbb06dd8ce17: Pushed
080712c21032: Pushed
abc85eb827e8: Pushed
2efc4bf7789c: Pushed
d0c61d9c30e4: Pushed
67246b9bbb93: Layer already exists
a1ce792246f9: Layer already exists
af1fa49a98d8: Layer already exists
7cd52847ad77: Layer already exists
deployment-01GVSS07G8ZVQTX6RZ8JH9B5W6: digest: sha256:2c482ee77f1c506b822e5223b979a41aa585f8df85f35e818843ac6b93cb376e size: 2841
--> Pushing image done
image: registry.fly.io/queuepreview-frontend:deployment-01GVSS07G8ZVQTX6RZ8JH9B5W6
image size: 2.0 GB
==> Creating release
--> release v33 created
--> You can detach the terminal anytime without stopping the deployment
==> Monitoring deployment
Logs: https://fly.io/apps/queuepreview-frontend/monitoring
1 desired, 1 placed, 1 healthy, 0 unhealthy [health checks: 1 total, 1 passing]
--> v33 deployed successfully
Current runner version: '2.303.0'
Operating System
Runner Image
Runner Image Provisioner
GITHUB_TOKEN Permissions
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:24cb9080177205b6e8c946b17badbe402adc938f)
Download action repository 'superfly/flyctl-actions@master' (SHA:dfdfedc86b296f5e5384f755a18bf400409a15d0)
Complete job name: Deploy
1s
Run actions/checkout@v3
Syncing repository: QueuePreview/app
Getting Git version info
Temporarily overriding HOME='/home/runner/work/_temp/9117a533-7201-46c2-8045-fb305fd65ac6' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
/usr/bin/git config --global --add safe.directory /home/runner/work/app/app
Deleting the contents of '/home/runner/work/app/app'
Initializing the repository
Disabling automatic garbage collection
Setting up auth
Fetching the repository
Determining the checkout info
Checking out the ref
/usr/bin/git log -1 --format='%H'
'f999ef135f0155782f7aeb12e1a1c7008eb7ef7f'
1s
Run superfly/flyctl-actions/setup-flyctl@master
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/f00e1106-03f4-4295-9637-b890256f1a9c -f /home/runner/work/_temp/65b6d203-7014-4b5c-b67b-be8232ffaf75
flyctl 0.0.492 is installed
2m 49s
Run flyctl deploy --remote-only
==> Verifying app config
--> Verified app config
==> Building image
Waiting for remote builder fly-builder-holy-sun-5178...
Remote builder fly-builder-holy-sun-5178 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
#1 [internal] load remote build context
Sending build context to Docker daemon 2.524MB
#1 DONE 0.7s
#1 [internal] load remote build context
#1 DONE 0.0s
#2 copy /context /
#2 DONE 0.1s
#3 [internal] load metadata for docker.io/library/node:16-alpine
#3 DONE 0.2s
#4 [1/9] FROM docker.io/library/node:16-alpine@sha256:fcb03294d3c0695cf9762dec94c0366f08e7a8c6a3c1e062d38c80ac30684d8a
#4 DONE 0.0s
#5 [2/9] RUN apk add --no-cache libc6-compat
#5 CACHED
#6 [3/9] WORKDIR /app
#6 CACHED
#7 [4/9] COPY . .
#7 DONE 0.0s
#8 [5/9] RUN yarn set version berry
#8 1.102 ➤ YN0000: Retrieving https://repo.yarnpkg.com/3.5.0/packages/yarnpkg-cli/bin/yarn.js
#8 1.594 ➤ YN0000: Saving the new release in .yarn/releases/yarn-3.5.0.cjs
#8 1.605 ➤ YN0000: Done in 0s 504ms
#8 DONE 1.6s
#9 [6/9] RUN yarn
#9 1.138 ➤ YN0000: ┌ Resolution step
#9 1.853 ➤ YN0000: └ Completed in 0s 714ms
#9 1.855 ➤ YN0000: ┌ Fetch step
#9 132.4 ➤ YN0000: └ Completed in 2m 11s
#9 132.5 ➤ YN0000: ┌ Link step
#9 152.3 ➤ YN0007: │ turbo@npm:1.8.3 must be built because it never has been before or the last one failed
#9 152.3 ➤ YN0007: │ esbuild@npm:0.14.47 must be built because it never has been before or the last one failed
#9 152.3 ➤ YN0007: │ esbuild@npm:0.16.17 must be built because it never has been before or the last one failed
#9 152.3 ➤ YN0007: │ esbuild@npm:0.17.5 must be built because it never has been before or the last one failed
#9 152.9 ➤ YN0007: │ queuepreview@workspace:. must be built because it never has been before or the last one failed
#9 152.9 ➤ YN0007: │ vercel@npm:28.13.1 must be built because it never has been before or the last one failed
#9 161.6 ➤ YN0009: │ queuepreview@workspace:. couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-1be077b0/build.log)
#9 161.6 ➤ YN0000: └ Completed in 29s 48ms
#9 161.8 ➤ YN0000: Failed with errors in 2m 41s
#9 ERROR: executor failed running [/bin/sh -c yarn]: exit code: 1
------
> [6/9] RUN yarn:
#9 132.5 ➤ YN0000: ┌ Link step
#9 152.3 ➤ YN0007: │ turbo@npm:1.8.3 must be built because it never has been before or the last one failed
#9 152.3 ➤ YN0007: │ esbuild@npm:0.14.47 must be built because it never has been before or the last one failed
#9 152.3 ➤ YN0007: │ esbuild@npm:0.16.17 must be built because it never has been before or the last one failed
#9 152.3 ➤ YN0007: │ esbuild@npm:0.17.5 must be built because it never has been before or the last one failed
#9 152.9 ➤ YN0007: │ queuepreview@workspace:. must be built because it never has been before or the last one failed
#9 152.9 ➤ YN0007: │ vercel@npm:28.13.1 must be built because it never has been before or the last one failed
#9 161.6 ➤ YN0009: │ queuepreview@workspace:. couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-1be077b0/build.log)
#9 161.6 ➤ YN0000: └ Completed in 29s 48ms
#9 161.8 ➤ YN0000: Failed with errors in 2m 41s
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c yarn]: exit code: 1
Error: Process completed with exit code 1.
0s
Post job cleanup.
/usr/bin/git version
git version 2.39.2
Temporarily overriding HOME='/home/runner/work/_temp/74f0becf-7fb1-4c60-a608-614363991ce8' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
/usr/bin/git config --global --add safe.directory /home/runner/work/app/app
/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
http.https://github.com/.extraheader
/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
0s
Cleaning up orphan processes
Terminate orphan process: pid (1695) (flyctl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment