Skip to content

Instantly share code, notes, and snippets.

@Kyu

Kyu/Dockerfile Secret

Last active March 7, 2023 02:28
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/562d2cb7d86b2c2b8a8de8b166065d07 to your computer and use it in GitHub Desktop.
Save Kyu/562d2cb7d86b2c2b8a8de8b166065d07 to your computer and use it in GitHub Desktop.
# Install dependencies only when needed
FROM node:16-alpine 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
ENV NEXT_TELEMETRY_DISABLED 1
# 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"]
# 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"
# https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
# https://stackoverflow.com/a/61892639/3875151
# For GH action
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 }}
2m 27s
Run flyctl deploy --remote-only
==> Verifying app config
--> Verified app config
==> Building image
Waiting for remote builder fly-builder-cold-wind-649...
Remote builder fly-builder-cold-wind-649 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.479MB
#1 DONE 3.1s
#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.3s
#4 [1/8] FROM docker.io/library/node:16-alpine@sha256:95a849eafc573ad0d972fd67c569369e7aa94d55a21ede3b972e3137e5f8e43a
#4 DONE 0.0s
#5 [2/8] RUN apk add --no-cache libc6-compat
#5 CACHED
#6 [3/8] WORKDIR /app
#6 CACHED
#7 [4/8] COPY . .
#7 DONE 0.1s
#8 [5/8] RUN yarn
#8 1.137 ➤ YN0000: ┌ Resolution step
#8 1.751 ➤ YN0000: └ Completed in 0s 613ms
#8 1.752 ➤ YN0000: ┌ Fetch step
#8 108.3 ➤ YN0000: └ Completed in 1m 47s
#8 108.4 ➤ YN0000: ┌ Link step
#8 127.6 ➤ YN0007: │ turbo@npm:1.7.0 must be built because it never has been before or the last one failed
#8 127.6 ➤ YN0007: │ esbuild@npm:0.14.47 must be built because it never has been before or the last one failed
#8 127.6 ➤ YN0007: │ esbuild@npm:0.16.17 must be built because it never has been before or the last one failed
#8 127.6 ➤ YN0007: │ esbuild@npm:0.17.5 must be built because it never has been before or the last one failed
#8 128.0 ➤ YN0007: │ queuepreview@workspace:. must be built because it never has been before or the last one failed
#8 128.0 ➤ YN0007: │ vercel@npm:28.13.1 must be built because it never has been before or the last one failed
#8 137.7 ➤ YN0009: │ queuepreview@workspace:. couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-36c8d29c/build.log)
#8 137.7 ➤ YN0000: └ Completed in 29s 280ms
#8 138.0 ➤ YN0000: Failed with errors in 2m 17s
#8 ERROR: executor failed running [/bin/sh -c yarn]: exit code: 1
------
> [5/8] RUN yarn:
#8 108.4 ➤ YN0000: ┌ Link step
#8 127.6 ➤ YN0007: │ turbo@npm:1.7.0 must be built because it never has been before or the last one failed
#8 127.6 ➤ YN0007: │ esbuild@npm:0.14.47 must be built because it never has been before or the last one failed
#8 127.6 ➤ YN0007: │ esbuild@npm:0.16.17 must be built because it never has been before or the last one failed
#8 127.6 ➤ YN0007: │ esbuild@npm:0.17.5 must be built because it never has been before or the last one failed
#8 128.0 ➤ YN0007: │ queuepreview@workspace:. must be built because it never has been before or the last one failed
#8 128.0 ➤ YN0007: │ vercel@npm:28.13.1 must be built because it never has been before or the last one failed
#8 137.7 ➤ YN0009: │ queuepreview@workspace:. couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-36c8d29c/build.log)
#8 137.7 ➤ YN0000: └ Completed in 29s 280ms
#8 138.0 ➤ YN0000: Failed with errors in 2m 17s
------
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c yarn]: exit code: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment