Skip to content

Commit

Permalink
feat: fly.io vm
Browse files Browse the repository at this point in the history
  • Loading branch information
kristobalus committed Nov 30, 2023
1 parent 10a9dc7 commit 80796bb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ RUN nimble build -d:danger -d:lto -d:strip \
FROM alpine:latest
WORKDIR /src/
RUN apk --no-cache add pcre ca-certificates
COPY --from=nim /src/nitter/entrypoint.sh ./
COPY --from=nim /src/nitter/nitter ./
COPY --from=nim /src/nitter/nitter.example.conf ./nitter.conf
COPY --from=nim /src/nitter/public ./public
Expand Down
28 changes: 28 additions & 0 deletions Dockerfile.fly
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM nimlang/nim:2.0.0-alpine-regular as nim
LABEL maintainer="setenforce@protonmail.com"

RUN apk --no-cache add libsass-dev pcre

WORKDIR /src/nitter

COPY nitter.nimble .
RUN nimble install -y --depsOnly

COPY . .
RUN nimble build -d:danger -d:lto -d:strip \
&& nimble scss \
&& nimble md

COPY entrypoint.sh .

FROM alpine:latest
WORKDIR /src/
RUN apk --no-cache add pcre ca-certificates
COPY --from=nim /src/nitter/entrypoint.sh ./
COPY --from=nim /src/nitter/nitter ./
COPY --from=nim /src/nitter/nitter.example.conf ./nitter.conf
COPY --from=nim /src/nitter/public ./public
EXPOSE 8080
RUN adduser -h /src/ -D -s /bin/sh nitter
USER nitter
ENTRYPOINT ["/src/entrypoint.sh"]
21 changes: 21 additions & 0 deletions build-image-fly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Read the version from package.json
VERSION=1.0.6-fly
IMAGE=kristobalus/nitter
echo "building image $IMAGE using buildx..."

docker buildx create --use --name buildx_instance --driver docker-container --bootstrap
docker buildx build -f ./Dockerfile.fly \
--progress=plain \
--build-arg VERSION="$VERSION" \
--label "build-tag=build-artifact" \
--platform linux/amd64 \
-t $IMAGE:$VERSION \
--push . || { echo "failed to build docker image"; exit 1; }

# commented out to keep cached layers
# docker buildx rm buildx_instance
docker tag $IMAGE:$VERSION $IMAGE:latest-fly
docker push $IMAGE:latest-fly
docker image prune -f --filter label=build-tag=build-artifact
2 changes: 1 addition & 1 deletion build-image.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Read the version from package.json
VERSION=1.0.5
VERSION=1.0.6
IMAGE=kristobalus/nitter
echo "building image $IMAGE using buildx for multi-arch..."

Expand Down
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# fly.toml app configuration file generated for api-nitter-falling-grass-9965-broken-thunder-6567-little-sun-5214 on 2023-11-29T10:42:16+06:00
# fly.toml app configuration file generated for api-nitter on 2023-11-30T12:35:49+06:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
Expand Down

0 comments on commit 80796bb

Please sign in to comment.