Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐳 Docker Updates #101

Merged
merged 26 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
482881d
:arrow_up: bump(deps): Update azure/container-scan commit hash to b53…
renovate-bot Feb 6, 2022
05095a9
Update docker-scan binary from hash -> v0.1
joshuanianji Feb 6, 2022
b2fca6c
Update `.dockerignore`
joshuanianji Feb 7, 2022
eae917c
Remove `turbo.json`
joshuanianji Feb 7, 2022
0e28686
Lock turbo version in Dockerfile
joshuanianji Feb 7, 2022
c0a06ec
Update `turbo.json`: baseBranch
joshuanianji Feb 7, 2022
e18eaeb
Dockerfiles work
joshuanianji Feb 7, 2022
bdf5573
Use my own `scratch-node-dumb-init`
joshuanianji Feb 8, 2022
463ea03
Cache docker image layers
joshuanianji Feb 8, 2022
f3ddd32
ci: :green_heart: add `shell` to composite action
joshuanianji Feb 8, 2022
1af3e5e
So not login to github when building docker image
joshuanianji Feb 8, 2022
47bb081
`docker images` before running `docker-compose up`
joshuanianji Feb 8, 2022
104e9c3
Idk how to fix the docker errors
joshuanianji Feb 8, 2022
65fd822
Add load: true
joshuanianji Feb 8, 2022
0eb58dd
Split `test.yml` to make it run faster
joshuanianji Feb 8, 2022
4743e38
Add tags to docker image cache
joshuanianji Feb 8, 2022
3ccdb72
Use docker caching for docker-compose
joshuanianji Feb 8, 2022
a552464
Fix whitespace issues
joshuanianji Feb 8, 2022
f0676b9
Build image is separate from scan
joshuanianji Feb 8, 2022
78cdcab
CI changes
joshuanianji Feb 8, 2022
cb59cde
MOre changes
joshuanianji Feb 8, 2022
3ebb8a2
Merge branch 'main' into update-dockerignore
joshuanianji Feb 8, 2022
8444230
asdasd
joshuanianji Feb 8, 2022
7c633f2
Merge branch 'main' into update-dockerignore
joshuanianji Feb 8, 2022
7cf226c
Remove CVE-2021-3807
joshuanianji Feb 8, 2022
0cedcab
Merge branch 'update-dockerignore' of github.com:joshuanianji/poopoo-…
joshuanianji Feb 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ out/
.github/
# ignore all .gitignore files
**/.gitignore
**/.turbo

# no need for .vscode
.vscode

*.md
!README*.md

# https://nodejs.org/en/docs/guides/nodejs-docker-webapp/#dockerignore-file
**/node_modules
npm-debug.log

# Docker Stuff
.dockerignore
**/Dockerfile

# Svelte-kit specific stuff
# Netlify
**/.netlify
**/svelte-kit
netlify.toml

# Other stuff
renovate.json
**/.turbo
1 change: 0 additions & 1 deletion .github/actions/build-docker-image-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ inputs:
required: true
description: "tags to add to the image"


runs:
using: composite
steps:
Expand Down
2 changes: 0 additions & 2 deletions .github/containerscan/allowedlist.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
general:
vulnerabilities:
- CVE-2021-3807 # ansi-regex vulnerability.
bestPracticeViolations:
- DKL-DI-0006 # avoid latest tag
- CIS-DI-0005 # avoid insecure registry
Expand Down
13 changes: 6 additions & 7 deletions apps/bot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM node:16-alpine3.12 AS base
# Ensure we prune workspace so we don't unnecessarily build so much

FROM base AS turboed
RUN yarn global add turbo
RUN yarn global add turbo@1.1.1

# Prune the workspace for the `frontend` app
FROM turboed AS pruner
Expand All @@ -28,16 +28,15 @@ RUN yarn --pure-lockfile --no-cache
FROM installer AS builder
WORKDIR /app
COPY --from=pruner /app/out/full/ .
COPY --from=pruner /app/turbo.json ./turbo.json
RUN yarn turbo run build --scope=bot --include-dependencies --no-deps
# Clear dev dependencies (e.g. turbo, tsc)
RUN npm prune --production

# Start the app
# Copy over `build/index.js`
FROM base AS runner
RUN apk add --no-cache dumb-init
WORKDIR /app
USER node
COPY --chown=node:node --from=builder /app/apps/bot/build/index.js ./index.js
FROM ghcr.io/joshuanianji/scratch-node-dumb-init:16.12.0 as runner
COPY --from=builder /app/apps/bot/build/index.js /index.js
ENV NODE_ENV production
CMD ["dumb-init", "node", "index.js"]

CMD ["node", "index.js"]
16 changes: 7 additions & 9 deletions apps/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM node:16-alpine3.12 AS base
# Ensure we prune workspace so we don't unnecessarily build so much

FROM base AS turboed
RUN yarn global add turbo
RUN yarn global add turbo@1.1.1

# Prune the workspace for the `frontend` app
# Use the turboed image to use the `turbo` command before we install dependencies.
Expand All @@ -30,17 +30,15 @@ RUN yarn --pure-lockfile --no-cache
FROM installer AS builder
WORKDIR /app
COPY --from=pruner /app/out/full/ .
COPY --from=pruner /app/turbo.json ./turbo.json
RUN yarn turbo run build --scope=server --include-dependencies --no-deps

# Copy over `build/index.js` and assets folder
FROM base AS runner
RUN apk add --no-cache dumb-init
WORKDIR /app
COPY --chown=node:node --from=builder /app/apps/server/build/index.js ./index.js
COPY --chown=node:node --from=builder /app/apps/server/assets/ ./assets/
FROM ghcr.io/joshuanianji/scratch-node-dumb-init:16.12.0 as runner
COPY --from=builder /app/apps/server/build/index.js /index.js
COPY --from=builder /app/apps/server/assets/ /assets/
EXPOSE 3001
USER node
ENV NODE_ENV production
CMD ["dumb-init", "node", "index.js"]
CMD ["node", "index.js"]

HEALTHCHECK CMD curl --fail http://localhost:3001 || exit 1
HEALTHCHECK CMD curl --fail http://localhost:3001 || exit 1
10 changes: 3 additions & 7 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{
"baseBranch": "origin/main",
"pipeline": {
"start": {
"cache": false
},
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**",
".next/**"
]
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**"]
},
"lint": {
"outputs": []
Expand Down