mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-04-23 19:32:11 +00:00
feat: prebuild out of docker
This commit is contained in:
parent
99937efcd8
commit
725844d8dc
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@ -62,13 +62,28 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
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
|
- name: Build and push
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64 # ${{ matrix.platform }}
|
platforms: linux/amd64,linux/arm64 # ${{ matrix.platform }}
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile.github-actions
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
|
40
Dockerfile.github-actions
Normal file
40
Dockerfile.github-actions
Normal 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"]
|
Loading…
x
Reference in New Issue
Block a user