yusing / go-proxy

Easy to use reverse proxy with docker integration
MIT License
99 stars 4 forks source link

Trouble using go-proxy #1

Closed ExodosPavilion closed 6 months ago

ExodosPavilion commented 6 months ago

I followed the instructions on the readme and go-proxy failed to install. It gave the following error:

[+] Building 1.9s (6/8)                                                                                                                                                                           docker:default
 => [app internal] load .dockerignore                                                                                                                                                                       0.2s
 => => transferring context: 2B                                                                                                                                                                             0.0s
 => [app internal] load build definition from Dockerfile                                                                                                                                                    0.3s
 => => transferring dockerfile: 268B                                                                                                                                                                        0.0s
 => [app internal] load metadata for docker.io/library/alpine:latest                                                                                                                                        0.9s
 => [app 1/4] FROM docker.io/library/alpine:latest@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b                                                                                  0.0s
 => [app internal] load build context                                                                                                                                                                       0.2s
 => => transferring context: 3.50kB                                                                                                                                                                         0.0s
 => ERROR [app 2/4] COPY bin/go-proxy /usr/bin                                                                                                                                                              0.0s
------
 > [app 2/4] COPY bin/go-proxy /usr/bin:
------
failed to solve: failed to compute cache key: failed to calculate checksum of ref e0fbef81-de73-4cdb-aec8-01d27aa9830f::tcw7n4rpl2ffetnrbzrfamre0: "/bin/go-proxy": not found

Upon looking into it there really was no bin/go-proxy folder but there was a src/go-proxy folder so a quick edit in the Dockerfile to replace bin with src lead to this:

[+] Building 2.8s (8/8) FINISHED                                                                                                                                                                  
----------------------------
[Cut out cause its a repeat]
----------------------------
 => => transferring context: 8.76kB                                                                                                                                                                         0.0s
 => CACHED [app 2/4] COPY src/go-proxy /usr/bin                                                                                                                                                             0.0s
 => CACHED [app 3/4] COPY templates/ /app/templates                                                                                                                                                         0.0s
 => ERROR [app 4/4] RUN chmod +rx /usr/bin/go-proxy                                                                                                                                                         1.0s
------
 > [app 4/4] RUN chmod +rx /usr/bin/go-proxy:
0.703 chmod: /usr/bin/go-proxy: No such file or directory
------
failed to solve: process "/bin/sh -c chmod +rx /usr/bin/go-proxy" did not complete successfully: exit code: 1

Seems like it can't find the go-proxy folder and its content so I edited the Dockerfile again so that COPY src/go-proxy /usr/bin becomes COPY src/go-proxy /usr/bin/go-proxy and did docker compose up -d again

[+] Building 2.1s (9/9) FINISHED                                                                                                                                                                  docker:default
----------------------------
[Cut out cause its a repeat]
----------------------------
 => CACHED [app 3/4] COPY templates/ /app/templates                                                                                                                                                         0.0s
 => CACHED [app 4/4] RUN chmod +rx /usr/bin/go-proxy                                                                                                                                                        0.0s
 => [app] exporting to image                                                                                                                                                                                0.1s
 => => exporting layers                                                                                                                                                                                     0.0s
 => => writing image sha256:de882e6d7a203ed5f255a32724bc24211f5114f68c6d11bbbadb183d79c4cbd8                                                                                                                0.0s
 => => naming to docker.io/library/go-proxy-app                                                                                                                                                             0.1s
[+] Running 0/1
 ⠹ Container go-proxy  Starting
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "go-proxy": executable file not found in $PATH: unknown

And I don't know how to fix even begin fixing that error. My final Dockerfile for reference:

FROM alpine:latest

LABEL maintainer="yusing@6uo.me"

COPY src/go-proxy /usr/bin/go-proxy
COPY templates/ /app/templates

RUN chmod +rx /usr/bin/go-proxy
ENV DOCKER_HOST unix:///var/run/docker.sock

EXPOSE 80
EXPOSE 443

CMD ["go-proxy"]

My compose.yml file for reference:

version: '3'
services:
  app:
    build: .
    container_name: go-proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /home/exodos/.container-configs/certs/cert.pem:/certs/cert.crt:ro
      - /home/exodos/.container-configs/certs/privkey.pem:/certs/priv.key:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    extra_hosts:
      - host.docker.internal:host-gateway
    logging:
      driver: 'json-file'
      options:
        max-file: '1'
        max-size: 128k

Any Idea on what I might be messing up when installing this?

yusing commented 6 months ago

My bad sorry! I forgot to remove bin/ from gitignore, you can also run build.sh to build the go binary.

yusing commented 6 months ago

Should now be fixed, please check~ I also tidied up the README for clearer instructions