Skip to content

Commit 61547a9

Browse files
author
Fly.io
committed
New files from Fly.io Launch
1 parent f90e76b commit 61547a9

File tree

3 files changed

+55
-33
lines changed

3 files changed

+55
-33
lines changed

.dockerignore

100644100755
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
1+
# Dependency/Build Directories
12
node_modules
3+
npm-debug.log
4+
.npm
5+
6+
# Project Files
7+
.git
8+
.gitignore
9+
.dockerignore
10+
Dockerfile
11+
fly.toml # Fly.io configuration file
12+
13+
# Environment/Configuration Files
14+
.env
215
.DS_Store
16+
*.log
17+
18+
# Development/Testing files and directories (adjust as needed)
19+
test
20+
tests
21+
docs
22+
coverage
23+
tmp
24+
*~
25+
# Any files generated during development or testing, e.g.:
26+
dist
27+
build

Dockerfile

100644100755
Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
1-
# syntax = docker/dockerfile:1
1+
# Stage 1: Build the Application
2+
# We use node:22 as the base for building and installing dependencies.
3+
FROM node:22 AS build
24

3-
# Adjust NODE_VERSION as desired
4-
ARG NODE_VERSION=22.16.0
5-
FROM node:${NODE_VERSION}-slim AS base
5+
# Set the working directory inside the container
6+
WORKDIR /usr/src/app
67

7-
LABEL fly_launch_runtime="Node.js"
8+
# Copy package.json and package-lock.json first to leverage Docker caching.
9+
# If these files don't change, subsequent builds can skip 'npm install'.
10+
COPY package*.json ./
811

9-
# Node.js app lives here
10-
WORKDIR /app
12+
# Install dependencies
13+
RUN npm install
1114

12-
# Set production environment
13-
ENV NODE_ENV="production"
14-
ARG YARN_VERSION=1.22.5
15-
RUN npm install -g yarn@$YARN_VERSION --force
16-
17-
18-
# Throw-away build stage to reduce size of final image
19-
FROM base AS build
20-
21-
# Install packages needed to build node modules
22-
RUN apt-get update -qq && \
23-
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
15+
# Copy the rest of the application source code
16+
COPY . .
2417

25-
# Install node modules
26-
COPY package-lock.json package.json yarn.lock ./
27-
RUN yarn install --frozen-lockfile
18+
# Stage 2: Create the Final Production Image
19+
# We use node:22 as the runtime image with all the necessary tools.
20+
FROM node:22
2821

29-
# Copy application code
30-
COPY . .
22+
# Set the working directory
23+
WORKDIR /usr/src/app
3124

25+
# Copy the node_modules and built application files from the 'build' stage
26+
COPY --from=build /usr/src/app/node_modules ./node_modules
27+
COPY --from=build /usr/src/app/package*.json ./
28+
COPY --from=build /usr/src/app .
3229

33-
# Final stage for app image
34-
FROM base
30+
# Expose the port your app runs on
31+
ENV PORT=8080
32+
EXPOSE $PORT
3533

36-
# Copy built application
37-
COPY --from=build /app /app
34+
# Run the application using the non-root user (recommended for security)
35+
USER node
3836

39-
# Start the server by default, this can be overwritten at runtime
40-
EXPOSE 3000
41-
CMD [ "yarn", "run", "start" ]
37+
# Define the command to start your application
38+
CMD [ "node", "index.js" ]

fly.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# fly.toml app configuration file generated for flog-it on 2025-12-13T01:40:45Z
1+
# fly.toml app configuration file generated for flog-it on 2025-12-14T22:05:26Z
22
#
33
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
44
#
@@ -9,7 +9,7 @@ primary_region = 'syd'
99
[build]
1010

1111
[http_service]
12-
internal_port = 3001
12+
internal_port = 8080
1313
force_https = true
1414
auto_stop_machines = 'stop'
1515
auto_start_machines = true

0 commit comments

Comments
 (0)