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

Dockerfile #12

Open
gpasqualetti opened this issue Apr 1, 2023 · 6 comments
Open

Dockerfile #12

gpasqualetti opened this issue Apr 1, 2023 · 6 comments

Comments

@gpasqualetti
Copy link

I have been tried to run gpodder2go in a dockerized environment but I have not been fully successful yet. I was wondering if somebody already managed to do it.

This is the Dockerfile I wrote (not working)

# Use a base image
FROM golang:1.16-alpine

ENV VERIFIER_SECRET_KEY='test'
EXPOSE 3005

# Set working directory
WORKDIR /app

# Install dependencies
# Musl-dev is required to fix stdlib.h
RUN apk update && apk add --no-cache wget git gcc musl-dev make sqlite 
RUN apk add --no-cache curl \     
  && curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.linux-armv7.tar.gz | tar xzv \
  && mv migrate /usr/local/bin/migrate \     
  && apk del curl

# Pull source code
RUN git clone https://github.com/oxtyped/gpodder2go.git /app/gpodder2go

# Make
RUN cd /app/gpodder2go && make build

# Init
RUN cd gpodder2go && ./gpodder2go init

# Run
CMD ["sh", "-c", "echo $VERIFIER_SECRET_KEY && /app/gpodder2go/gpodder2go serve"]

# Create a new user
RUN cd /app/gpodder2go && ./gpodder2go accounts create username --email="myemail@test.com" --name="MyName" --password="mypasswd"

I build and run it with

docker build . -t gpodder2go:latest
docker run -dp 3005:3005 gpodder2go:latest

When I look at the the logs it seems like being starting fine.

2023/04/01 17:30:15 💻 Starting server at localhost:3005

However, when I try to sync with AntennaPod, it sais that the connection failed. Same thing with the gPodder Desktop client. Any hint?

@gpasqualetti
Copy link
Author

I managed to solve. The problem was the binding to localhost in the CMD command. The following Dockerfile works:

# Use a base image
FROM golang:1.16-alpine

ENV VERIFIER_SECRET_KEY='test'
EXPOSE 3005

# Set working directory
WORKDIR /app

# Install dependencies
# Musl-dev is required to fix stdlib.h
RUN apk update && apk add --no-cache wget git gcc musl-dev make sqlite 
RUN apk add --no-cache curl \     
  && curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.linux-armv7.tar.gz | tar xzv \
  && mv migrate /usr/local/bin/migrate \     
  && apk del curl

# Pull source code
RUN git clone https://github.com/oxtyped/gpodder2go.git /app/gpodder2go

# Make
RUN cd /app/gpodder2go && make build

# Init
RUN cd gpodder2go && ./gpodder2go init

# Run
CMD ["sh", "-c", "echo $VERIFIER_SECRET_KEY && cd /app/gpodder2go && ./gpodder2go serve -b 0.0.0.0:3005"]

# Create a new user
RUN cd /app/gpodder2go && ./gpodder2go accounts create username --email="myemail@test.com" --name="MyName" --password="mypasswd"

With docker-compose:

version: '3.9'

services:
  gpodder2go:
    container_name: gpodder2go
    build:
      context: ./gpodder2go
      dockerfile: Dockerfile
    ports:       
      - "3005:3005"
    volumes:
      - ./gpodder2go/g2g.db:/app/gpodder2go/g2g.db

It might be necessary to create an empty g2g.db file the first time before mounting.

Maybe it could be worth sharing this info in the documentation.

@1Yanik3
Copy link

1Yanik3 commented Apr 18, 2023

In case anyone else is having this same issue, I created an automatically updating Docker image with everything setup and working. You can find it here: https://gitlab.com/ConfusedAnt/gpodder2go

@oxtyped
Copy link
Owner

oxtyped commented Apr 18, 2023

Thanks for sharing this!

@hadleyrich
Copy link

hadleyrich commented May 17, 2023

Note for people using this that as mentioned above which I missed initially you may need to touch g2g.db before running lest docker creates the volume as a directory instead of a file.

@dgalli1
Copy link

dgalli1 commented Oct 6, 2023

In case anyone else is having this same issue, I created an automatically updating Docker image with everything setup and working. You can find it here: https://gitlab.com/ConfusedAnt/gpodder2go

You might want to add into your README how you can set the env key and choose a different port.

    ports:
      - 8114:80
    environment:
      - VERIFIER_SECRET_KEY=ETiUYBjkR5qcu

Also, a hint about where the binary is would be helpful:

docker compose exec app /gpodder2go init
docker compose exec app /gpodder2go accounts

@peterpepo
Copy link

In case anyone else is having this same issue, I created an automatically updating Docker image with everything setup and working. You can find it here: https://gitlab.com/ConfusedAnt/gpodder2go

Can you build a raspberry pi image? At the moment it reports gpodder2go The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested when I try to run it on my rpi3b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants