Skip to content

Commit 52ef1e1

Browse files
authored
chore: add Dockerfile (#2)
1 parent 25c13fa commit 52ef1e1

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ RUN if [ "alpine" == "alpine" ] ; then apk update ; else apt-get update ; fi
1010
# Install Git
1111
RUN if [ "alpine" == "alpine" ] ; then apk add git ; else apt-get install -y git ; fi
1212

13+
RUN apt update \
14+
&& apt install -y curl
15+
ARG NODE_VERSION=20
16+
RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
17+
&& bash n $NODE_VERSION \
18+
&& rm n \
19+
&& npm install -g n

.devcontainer/devcontainer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"dockerComposeFile": "docker-compose.yml",
66
"service": "app",
77
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
"features": {
9+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
10+
},
11+
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
812
// Configure tool-specific properties.
913
"customizations": {
1014
// Configure properties specific to VS Code.
@@ -15,6 +19,7 @@
1519
"cweijan.vscode-postgresql-client2",
1620
"esbenp.prettier-vscode",
1721
"ms-azuretools.vscode-docker",
22+
"github.vscode-pull-request-github",
1823
"Prisma.prisma"
1924
],
2025
"settings": {

.dockerignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#.dockerignore
2+
3+
node_modules
4+
Dockerfile*
5+
docker-compose*
6+
.dockerignore
7+
.git
8+
.gitignore
9+
README.md
10+
LICENSE
11+
.vscode
12+
Makefile
13+
helm-charts
14+
.env
15+
.editorconfig
16+
.idea
17+
coverage*

Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# BASE Stage
2+
FROM oven/bun:1 AS base
3+
4+
# setup all global artifacts. why Node? A: https://github.com/oven-sh/bun/issues/4848
5+
RUN apt update \
6+
&& apt install -y curl
7+
8+
ARG NODE_VERSION=20
9+
RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \
10+
&& bash n $NODE_VERSION \
11+
&& rm n \
12+
&& npm install -g n
13+
14+
15+
# INSTALL Stage
16+
17+
# install dependencies into temp folder. this will cache them and speed up future builds
18+
FROM base AS install
19+
WORKDIR /temp/prod/
20+
COPY package.json bun.lockb ./
21+
RUN bun install --frozen-lockfile --production
22+
23+
24+
# PRERELEASE Stage
25+
26+
# copy node_modules from temp folder. then copy all (non-ignored) project files into the image
27+
FROM install AS prerelease
28+
29+
WORKDIR /usr/src/app
30+
31+
COPY --from=install /temp/prod/node_modules node_modules
32+
COPY . .
33+
RUN npx prisma generate
34+
35+
# RELEASE Stage
36+
37+
FROM base AS release
38+
COPY --from=prerelease /usr/src/app/node_modules ./node_modules
39+
COPY --from=prerelease /usr/src/app/index.ts .
40+
COPY --from=prerelease /usr/src/app/lib ./lib
41+
COPY --from=prerelease /usr/src/app/routes ./routes
42+
COPY --from=prerelease /usr/src/app/package.json .
43+
44+
# run the app
45+
USER bun
46+
EXPOSE 3003/tcp
47+
CMD ["bun", "run", "index.ts"]

0 commit comments

Comments
 (0)