Skip to content

Commit 19b0189

Browse files
authored
feat: Installs and configures Docker. (#86)
1 parent 89a0937 commit 19b0189

File tree

4 files changed

+145
-0
lines changed

4 files changed

+145
-0
lines changed

.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.classpath
8+
**/.dockerignore
9+
**/.env
10+
**/.git
11+
**/.gitignore
12+
**/.project
13+
**/.settings
14+
**/.toolstarget
15+
**/.vs
16+
**/.vscode
17+
**/.next
18+
**/.cache
19+
**/*.*proj.user
20+
**/*.dbmdl
21+
**/*.jfm
22+
**/charts
23+
**/docker-compose*
24+
**/compose.y*ml
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
**/build
32+
**/dist
33+
LICENSE
34+
README.md

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Comments are provided throughout this file to help you get started.
4+
# If you need more help, visit the Dockerfile reference guide at
5+
# https://docs.docker.com/go/dockerfile-reference/
6+
7+
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
8+
9+
ARG NODE_VERSION=22.12.0
10+
11+
FROM node:${NODE_VERSION}-alpine
12+
13+
# Use production node environment by default.
14+
ENV NODE_ENV production
15+
16+
17+
WORKDIR /usr/src/app
18+
19+
# Download dependencies as a separate step to take advantage of Docker's caching.
20+
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
21+
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
22+
# into this layer.
23+
RUN --mount=type=bind,source=package.json,target=package.json \
24+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
25+
--mount=type=cache,target=/root/.npm \
26+
npm ci --omit=dev
27+
28+
# Run the application as a non-root user.
29+
USER node
30+
31+
# Copy the rest of the source files into the image.
32+
COPY . .
33+
34+
# Expose the port that the application listens on.
35+
EXPOSE 8080
36+
37+
# Run the application.
38+
#CMD npm run start # This isn't really applicable.

README.Docker.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### Building and running your application
2+
3+
When you're ready, start your application by running:
4+
`docker compose up --build`.
5+
6+
Your application will be available at http://localhost:8080.
7+
8+
### Deploying your application to the cloud
9+
10+
First, build your image, e.g.: `docker build -t myapp .`.
11+
If your cloud uses a different CPU architecture than your development
12+
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
13+
you'll want to build the image for that platform, e.g.:
14+
`docker build --platform=linux/amd64 -t myapp .`.
15+
16+
Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.
17+
18+
Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
19+
docs for more detail on building and pushing.
20+
21+
### References
22+
* [Docker's Node.js guide](https://docs.docker.com/language/nodejs/)

compose.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Comments are provided throughout this file to help you get started.
2+
# If you need more help, visit the Docker Compose reference guide at
3+
# https://docs.docker.com/go/compose-spec-reference/
4+
5+
# Here the instructions define your application as a service called "server".
6+
# This service is built from the Dockerfile in the current directory.
7+
# You can add other services your application may depend on here, such as a
8+
# database or a cache. For examples, see the Awesome Compose repository:
9+
# https://github.com/docker/awesome-compose
10+
services:
11+
server:
12+
build:
13+
context: .
14+
environment:
15+
NODE_ENV: production
16+
ports:
17+
- 8080:8080
18+
19+
# The commented out section below is an example of how to define a PostgreSQL
20+
# database that your application can use. `depends_on` tells Docker Compose to
21+
# start the database before your application. The `db-data` volume persists the
22+
# database data between container restarts. The `db-password` secret is used
23+
# to set the database password. You must create `db/password.txt` and add
24+
# a password of your choosing to it before running `docker-compose up`.
25+
# depends_on:
26+
# db:
27+
# condition: service_healthy
28+
# db:
29+
# image: postgres
30+
# restart: always
31+
# user: postgres
32+
# secrets:
33+
# - db-password
34+
# volumes:
35+
# - db-data:/var/lib/postgresql/data
36+
# environment:
37+
# - POSTGRES_DB=example
38+
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
39+
# expose:
40+
# - 5432
41+
# healthcheck:
42+
# test: [ "CMD", "pg_isready" ]
43+
# interval: 10s
44+
# timeout: 5s
45+
# retries: 5
46+
# volumes:
47+
# db-data:
48+
# secrets:
49+
# db-password:
50+
# file: db/password.txt
51+

0 commit comments

Comments
 (0)