1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-04-23 11:22:10 +00:00

feat: prebuild out of docker

This commit is contained in:
Florian Bouillon 2025-03-28 15:54:40 +01:00
parent 99937efcd8
commit 725844d8dc
Signed by: Florian Bouillon
GPG Key ID: 7676FF78F3BC40EC
2 changed files with 56 additions and 1 deletions

View File

@ -62,13 +62,28 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Pre build server
run: |
bun install --frozen-lockfile
cd server
bun install --frozen-lockfile
bun run compile
rm -rf node_modules
cd ..
rm -rf node_modules
- name: Build and push
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64 # ${{ matrix.platform }}
file: ./Dockerfile
file: ./Dockerfile.github-actions
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha

40
Dockerfile.github-actions Normal file
View File

@ -0,0 +1,40 @@
FROM docker.io/oven/bun:1-alpine AS build
# go to work folder
WORKDIR /usr/src/app
# allow bun user to edit folder
RUN chown -R bun:bun .
USER bun
ADD --chown=bun:bun server/package.json server/bun.lockb ./server/
# install prod deps dependencies
RUN cd server && \
bun install --frozen-install --production
# go to another VM
FROM docker.io/oven/bun:1-alpine AS prod
# inform software to be in production
ENV NODE_ENV=production
# run as non root user
USER bun
# go to work folder
WORKDIR /usr/src/app
# copy from build image
COPY --chown=bun:bun /usr/src/app/server/public ./public
COPY --chown=bun:bun /usr/src/app/server/package.json ./package.json
COPY --chown=bun:bun --from=build /usr/src/app/server/node_modules ./node_modules
COPY --chown=bun:bun /usr/src/app/server/src ./src
COPY --chown=bun:bun /usr/src/app/server/generated ./generated
# Expose port
EXPOSE 3000
# run it !
CMD ["bun", "src/index.ts"]