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

failed to use unpublished( work-in-progressing) @atproto/api for ozone docker image, described hack in HACKING.md #87

Open
itaru2622 opened this issue Apr 7, 2024 · 3 comments
Labels
devex Related to development/deployment flow

Comments

@itaru2622
Copy link

HACKING.md describes how to use unpublished( work-in-progressing) atproto/api for ozone, in below section.
but this hack cannot use for building docker image as below error.
how can use unpublished atproto api in ozone docker image?

### Working with unpublished changes to the `@atproto/api` package

ozone/HACKING.md

Lines 57 to 65 in 7963bec

4. Update the package.json file in ozone/ to reference the local build of @atproto/api.
```diff
"dependencies": {
- "@atproto/api": "^0.0.3",
+ "@atproto/api": "link:../atproto/packages/api/dist",
"@headlessui/react": "^1.7.7",
```

docker build -t ozone .
 => [build 1/9] FROM docker.io/library/node:20.11-alpine3.18@sha...
 => [build 2/9] WORKDIR /usr/src/ozone
 => [build 3/9] COPY package.json yarn.lock .
 => [build 4/9] RUN yarn
 => [build 5/9] COPY . .
 => ERROR [build 6/9] RUN yarn build
------                                                                                                                                                                                                                           
 > [build 6/9] RUN yarn build:                                                                                                                                                                                                   
0.390 yarn run v1.22.19                                                                                                                                                                                                          
0.426 $ next build                                                                                                                                                                                                               
:
7.551 Failed to compile.
7.551 ./app/actions/ModActionPanel/BlobList.tsx
7.551 Module not found: Can't resolve '@atproto/api'
:
---
Dockerfile:8
--------------------
   6 |     RUN yarn
   7 |     COPY . .
   8 | >>> RUN yarn build
   9 |     RUN rm -rf node_modules .next/cache
  10 |     RUN mv service/package.json package.json && mv service/yarn.lock yarn.lock
@bnewbold
Copy link
Collaborator

bnewbold commented Apr 8, 2024

I'm not sure we have ever had the need to build a Docker image against a patched version of the api package? I can see why that might be desirable in some cases, but might not be something we support or provide documentation for.

@itaru2622
Copy link
Author

@bnewbold I understand that your point. it maybe rare case. but it is good that regardless published or un-published, code can work on docker (in same manner). for example, when developing new feature of atproto having impact on API, it becomes hard to make integration test on docker with ozone aheading publish(i.e posting new PR).

@bnewbold bnewbold added the devex Related to development/deployment flow label Apr 26, 2024
@itaru2622
Copy link
Author

itaru2622 commented Jul 25, 2024

below Dockerfile and ops could involve work-in-progressing codes for ozone docker container.

  1. put below Dockerfile as ozone/Dockerfile.dev
# put this content as ozone/Dockerfile.dev

FROM node:20.11-alpine3.18

RUN npm install -g pnpm
RUN apk add --update dumb-init

# host side toplevel dir is ~/Documents/bluesky which has atproto and ozone folders, as described in HACKING.md

# based on atproto/services/bsky/Dockerfile >>>>
COPY ./atproto /usr/src/atproto
WORKDIR /usr/src/atproto
RUN pnpm install --frozen-lockfile; \
    pnpm build;
RUN rm -rf node_modules; \
    pnpm install --prod --shamefully-hoist --frozen-lockfile --prefer-offline > /dev/null


# based on ozone/Dockerfile  >>>>
COPY ./ozone /usr/src/ozone
WORKDIR /usr/src/ozone

# for @atproto/api and @atproto/ozone, use work-in-progressing code as described in HACKING.md
RUN sed -i -r 's#"@atproto/(.+)": ".+"#"@atproto/\1": "link:../atproto/packages/\1/dist"#' ./package.json
RUN sed -i -r 's#"@atproto/(.+)": ".+"#"@atproto/\1": "link:../../atproto/packages/\1/dist"#' ./service/package.json

RUN yarn
RUN yarn build
RUN (cd service; yarn )
RUN cp -p /usr/src/atproto/packages/ozone/package.json /usr/src/atproto/packages/ozone/dist/package.json
RUN chown -R node:node /usr/src

EXPOSE 3000
ENV OZONE_PORT=3000
ENV NODE_ENV=production
USER node
CMD dumb-init -- node ./service

LABEL org.opencontainers.image.source=https://github.com/bluesky-social/ozone
LABEL org.opencontainers.image.description="Ozone Moderation Service Web UI"
LABEL org.opencontainers.image.licenses=MIT
  1. build docker image
# as described in HACKING.mdcd ~/Documents/bluesky

❯ ls -l
drwxr-xr-x  22 user  group  704 Jan 19 15:51 atproto
drwxr-xr-x  24 user  group  768 Jan 24 19:17 ozone

❯ ls ozone/Dockerfile.dev
ozone/Dockerfile.dev

❯ docker build -f ozone/Dockerfile.dev -t ozone:dev  .
  1. use the above image in ozone's compose.yaml at ozone/service/compose.yaml
  ozone:
    container_name: ozone
-   image: ghcr.io/bluesky-social/ozone:0.1
+   image: ozone:dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devex Related to development/deployment flow
Projects
None yet
Development

No branches or pull requests

2 participants