generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a33e9ea
commit 0723eee
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Include any files or directories that you don't want to be copied to your | ||
# container here (e.g., local build artifacts, temporary files, etc.). | ||
# | ||
# For more help, visit the .dockerignore file reference guide at | ||
# https://docs.docker.com/go/build-context-dockerignore/ | ||
|
||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/.next | ||
**/.cache | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/charts | ||
**/docker-compose* | ||
**/compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
**/build | ||
**/dist | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG NODE_VERSION=20.11.1 | ||
|
||
FROM node:${NODE_VERSION} AS build | ||
|
||
# Run the application as a non-root user. | ||
USER node | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# Download dependencies as a separate step to take advantage of Docker's caching. | ||
# Leverage a cache mount to /root/.yarn to speed up subsequent builds. | ||
# Leverage a bind mounts to package.json and yarn.lock to avoid having to copy them into | ||
# into this layer. | ||
RUN --mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,source=yarn.lock,target=yarn.lock \ | ||
--mount=type=cache,target=/root/.yarn \ | ||
yarn install --frozen-lockfile --ignore-scripts | ||
|
||
# Copy the rest of the source files into the image. | ||
COPY . . | ||
|
||
# Build the application. | ||
RUN yarn tsc | ||
|
||
################################################################################ | ||
|
||
#Production stage | ||
FROM node:${NODE_VERSION}-alpine AS production | ||
|
||
# Run the application as a non-root user. | ||
USER node | ||
|
||
# Use production node environment by default. | ||
ENV NODE_ENV production | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN --mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,source=yarn.lock,target=yarn.lock \ | ||
--mount=type=cache,target=/root/.yarn \ | ||
yarn install --production --frozen-lockfile --ignore-scripts | ||
|
||
# Copy the build 'dist/' into the image. | ||
COPY --from=build /usr/src/app/dist . | ||
|
||
# Expose the port that the application listens on. | ||
EXPOSE 3000 | ||
|
||
# Run the application. | ||
CMD ["node", "server.js"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
### Building and running your application | ||
|
||
When you're ready, start your application by running: | ||
`docker compose up --build`. | ||
|
||
Your application will be available at http://localhost:3000. | ||
|
||
### Deploying your application to the cloud | ||
|
||
First, build your image, e.g.: `docker build -t myapp .`. | ||
If your cloud uses a different CPU architecture than your development | ||
machine (e.g., you are on a Mac M1 and your cloud provider is amd64), | ||
you'll want to build the image for that platform, e.g.: | ||
`docker build --platform=linux/amd64 -t myapp .`. | ||
|
||
Then, push it to your registry, e.g. `docker push myregistry.com/myapp`. | ||
|
||
Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/) | ||
docs for more detail on building and pushing. | ||
|
||
### References | ||
* [Docker's Node.js guide](https://docs.docker.com/language/nodejs/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Comments are provided throughout this file to help you get started. | ||
# If you need more help, visit the Docker compose reference guide at | ||
# https://docs.docker.com/go/compose-spec-reference/ | ||
|
||
# Here the instructions define your application as a service called "server". | ||
# This service is built from the Dockerfile in the current directory. | ||
# You can add other services your application may depend on here, such as a | ||
# database or a cache. For examples, see the Awesome Compose repository: | ||
# https://github.com/docker/awesome-compose | ||
services: | ||
server: | ||
build: | ||
context: . | ||
environment: | ||
NODE_ENV: production | ||
DOCKER_BUILDKIT: 1 | ||
ENABLE_FILE_LOGS: true | ||
ENABLE_CONSOLE_LOGS: false | ||
ports: | ||
- 3000:3000 | ||
|