Beatbump icon indicating copy to clipboard operation
Beatbump copied to clipboard

docker-compose ?

Open EsmailELBoBDev2 opened this issue 3 years ago • 43 comments

Hi, can you build a docker-compose file for this project? It would be really awesome :)

EsmailELBoBDev2 avatar Mar 05 '22 20:03 EsmailELBoBDev2

Hey, I just got mostly setup on a new laptop since my old one was dying the past week. This is a good idea, I will be working on how to implement it since Docker would need the Node adapter and Beatbump uses the Cloudflare Workers adapter by default.

I been thinking over how to do it the past week and I decided that I would need to create some sort of prebuild “staging”, and potentially find a way to programmatically configure the environment it’ll be deployed to so I can reliably create working docker containers as well as typical adapter builds.

I’ll be sure to keep updating with any progress

snuffyDev avatar Mar 13 '22 11:03 snuffyDev

npm init svelte@next sveltekit-docker cd sveltekit-docker npm install @sveltejs/adapter-node@next --save-dev vi svelte.config.js # replace adapter-auto with adapter-node vi Dockerfile # add content docker build --no-cache -t sveltekit-docker:latest

patbhakta avatar Apr 13 '22 08:04 patbhakta

stage build

FROM node:16-alpine

WORKDIR /app

copy everything to the container

COPY . .

clean install all dependencies

RUN npm ci

remove potential security issues

RUN npm audit fix

build SvelteKit app

RUN npm run build

stage run

FROM node:16-alpine

WORKDIR /app

copy dependency list

COPY --from=0 /app/package*.json ./

clean install dependencies, no devDependencies, no prepare script

RUN npm ci --production --ignore-scripts

remove potential security issues

RUN npm audit fix

copy built SvelteKit app to /app

COPY --from=0 /app/build ./

EXPOSE 3000 CMD ["node", "./index.js"]

patbhakta avatar Apr 13 '22 08:04 patbhakta

run container as command (stop with Ctrl-C*)

docker run -it --rm --name sveltekit-docker -p 3000:3000 sveltekit-docker:latest

demonize container (send to background)

docker run -d --name sveltekit-docker -p 3000:3000 sveltekit-docker:latest

patbhakta avatar Apr 13 '22 08:04 patbhakta

Appreciate this! I’ve been slowly working on this, but have been busy, so your comments are helpful. I’ll hopefully be able to get this up and running soon!

snuffyDev avatar Apr 13 '22 18:04 snuffyDev

docker-compose...?

EsmailELBoBDev2 avatar Apr 13 '22 23:04 EsmailELBoBDev2

FROM node:18.1.0-alpine3.15 AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build && npm prune --production

FROM node:18.1.0-alpine3.15
USER node:node
WORKDIR /app
COPY --from=builder --chown=node:node /app/build ./build
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
COPY --chown=node:node package.json .
ENV PORT 5000
EXPOSE 5000
CMD ["node","build"]

patbhakta avatar May 09 '22 00:05 patbhakta

This aint docker-compose

I have been lied to

EsmailELBoBDev2 avatar May 09 '22 11:05 EsmailELBoBDev2

docker build -t beatbump .
Sending build context to Docker daemon  2.048kB
Step 1/15 : FROM node:18.1.0-alpine3.15 AS builder
18.1.0-alpine3.15: Pulling from library/node
df9b9388f04a: Already exists 
75d830d4694c: Pull complete 
8f5e371a64cc: Pull complete 
0c741fedcc2f: Pull complete 
Digest: sha256:f4d6916c5625853e81994b5cb53ad3eb27e5fec9451c579d298fee0c508fe621
Status: Downloaded newer image for node:18.1.0-alpine3.15
 ---> d94913fe64df
Step 2/15 : WORKDIR /app
 ---> Running in 1f7947c7e250
Removing intermediate container 1f7947c7e250
 ---> f8a84956a4ed
Step 3/15 : COPY package.json package-lock.json ./
COPY failed: file not found in build context or excluded by .dockerignore: stat package.json: file does not exist

EsmailELBoBDev2 avatar May 09 '22 12:05 EsmailELBoBDev2

Apologies for the delays, I promise I haven’t been ignoring this. I recently reinstalled Windows and am now setup enough, so I will setup Docker and play around with it to get an official implementation working

snuffyDev avatar May 10 '22 18:05 snuffyDev

I recently reinstalled Windows

image

Hope at least it's windows 10 AME (less bloat-y)


About docker, I'm no expert at docker so I could not play with Dockerfile so either gimme docker compose image or tell me how to deal with that docker file so I can test it

EsmailELBoBDev2 avatar May 10 '22 18:05 EsmailELBoBDev2

Okay so this is my first time using Docker. I don’t currently have it implemented in this repo but you can find a repo with what I’ve figured out so far here: https://github.com/snuffyDev/Beatbump-Docker

As for the docker image itself, I will reply when a usable image is uploaded to DockerHub. Currently the one uploaded works but doesn’t close the Node server that hosts Beatbump when you stop the container

snuffyDev avatar May 18 '22 11:05 snuffyDev

I believe it should be fixed now, so here's the DockerHub link: https://hub.docker.com/repository/docker/snuffydev/beatbump

docker run --publish 80:3000 docker.io/snuffydev/beatbump:latest

or create a docker-compose.yml file with this for its contents:

services:
  app:
    image: docker.io/snuffydev/beatbump:latest
    ports:
      - "443:3000"

then run it with docker compose -f "docker-compose.yml" up -d --build i believe

snuffyDev avatar May 18 '22 11:05 snuffyDev

I'll work on actually adding this to this repo though, and probably end up using GitHub actions to automate the dockerization process

snuffyDev avatar May 18 '22 17:05 snuffyDev

you sure its public? each time I go to https://hub.docker.com/repository/docker/snuffydev/beatbump I get to login page

EsmailELBoBDev2 avatar May 18 '22 17:05 EsmailELBoBDev2

Yeah it's public, you can pull the image though by using docker pull snuffydev/beatbump:latest in your terminal.

Worse comes to worse if you want a URL, you can try this link https://hub.docker.com/r/snuffydev/beatbump

snuffyDev avatar May 18 '22 17:05 snuffyDev

oh. well time to try!

EsmailELBoBDev2 avatar May 18 '22 18:05 EsmailELBoBDev2

:+1: https://beatbump.esmailelbob.xyz/home

EsmailELBoBDev2 avatar May 18 '22 18:05 EsmailELBoBDev2

Search function do not work: https://beatbump.esmailelbob.xyz/search/bad%2520habits?filter=EgWKAQIIAWoKEAMQBBAKEAkQBQ%3D%3D

app_1  | 2022-05-18T18:19:55.962058231Z TypeError: albumArr.at is not a function
app_1  | 2022-05-18T18:19:55.962089835Z     at file:///app/build/server/entries/endpoints/api/search.json.ts.js:132:30
app_1  | 2022-05-18T18:19:55.962096530Z     at Array.map (<anonymous>)
app_1  | 2022-05-18T18:19:55.962101990Z     at parseSong (file:///app/build/server/entries/endpoints/api/search.json.ts.js:120:19)
app_1  | 2022-05-18T18:19:55.962106291Z     at file:///app/build/server/entries/endpoints/api/search.json.ts.js:232:17
app_1  | 2022-05-18T18:19:55.962110861Z     at Array.map (<anonymous>)
app_1  | 2022-05-18T18:19:55.962114847Z     at parseSearchResult (file:///app/build/server/entries/endpoints/api/search.json.ts.js:212:7)
app_1  | 2022-05-18T18:19:55.962118951Z     at get (file:///app/build/server/entries/endpoints/api/search.json.ts.js:97:13)
app_1  | 2022-05-18T18:19:55.962125123Z     at runMicrotasks (<anonymous>)
app_1  | 2022-05-18T18:19:55.962137981Z     at processTicksAndRejections (node:internal/process/task_queues:96:5)
app_1  | 2022-05-18T18:19:55.962142637Z     at async render_endpoint (file:///app/build/server/index.js:155:20)

EsmailELBoBDev2 avatar May 18 '22 18:05 EsmailELBoBDev2

It's due to Array.prototype.at either not being there, or the data isn't the right type (array). I'll see if i can mess with the tsconfig.json and other stuff to get this fixed!

A more 'official' solution will be coming soon, but the update I'm working on right now is one of the biggest I've done. So in the meantime I'll do what I can to get this working as a 'proof-of-concept'!

snuffyDev avatar May 19 '22 08:05 snuffyDev

Okay, Good luck and I will wait your word when it get fixed (Wanna play shape of you :p)

EsmailELBoBDev2 avatar May 19 '22 08:05 EsmailELBoBDev2

Try it now! It works for me, expect an 'official' Docker setup in the very near future. My apologies for the delay! image

snuffyDev avatar May 31 '22 10:05 snuffyDev

oh it works :+1:

EsmailELBoBDev2 avatar May 31 '22 11:05 EsmailELBoBDev2

Just to make sure, is it my bad luck or I can't play songs and it's site problem

EsmailELBoBDev2 avatar May 31 '22 12:05 EsmailELBoBDev2

Seems to work for me, are you hosting it "locally"? "Locally" meaning within the same general region as you when trying to access the instance? It could possibly be due to geo-restrictions. Soon I should have this big update ready-to-go and will have a fix for that problem, if it's occuring at all.

I'll try to see if there's any issues within the code, but let me know if it resolves itself, or if it's an issue where some songs will play, and others don't.

snuffyDev avatar May 31 '22 12:05 snuffyDev

it's not locally, my server in Canada and I'm in Egypt so

I'm trying and it actually plays a song new rules in pop's biggest hits but like it's only song plays xD

EsmailELBoBDev2 avatar May 31 '22 13:05 EsmailELBoBDev2

Okay it plays some songs so I guess your theory is right, geo blocking

EsmailELBoBDev2 avatar May 31 '22 13:05 EsmailELBoBDev2

The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

When it is ready, could you please support arm64 also? Thanks

ezcafe avatar Jun 11 '22 10:06 ezcafe

The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

When it is ready, could you please support arm64 also? Thanks

As a arm64 user i created one based on Dockerfile mentioned above, martadinata666/beatbump:latest , hope official will released soon.

martadinata666 avatar Jun 12 '22 06:06 martadinata666

thanks @martadinata666

ezcafe avatar Jun 12 '22 12:06 ezcafe