diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f93f642 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,50 @@ +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# vercel +.vercel + +# IDEs +/.vscode/ +/.idea/ + +# cypress +cypress/videos +cypress/screenshots + +# next-pwa +**/public/workbox-*.js* +**/public/sw.js* +**/public/worker-*.js* + +# git +.git/ +.gitignore +.gitattributes diff --git a/.travis.yml b/.travis.yml index c2f1e38..337d13c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ os: linux dist: xenial +services: + - docker + addons: apt: packages: @@ -31,3 +34,10 @@ script: else yarn cy:run; fi' + +before_deploy: + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + +deploy: + provider: script + script: docker push thedaviddelta/lingva-translate diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8b5cace --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# https://nextjs.org/docs/deployment#docker-image + +FROM node:alpine AS deps +RUN apk add --no-cache libc6-compat +WORKDIR /app +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile + +FROM node:alpine AS builder +WORKDIR /app + +RUN addgroup -g 1001 -S nodejs +RUN adduser -S nextjs -u 1001 +COPY --chown=nextjs:nodejs . . +COPY --from=deps /app/node_modules ./node_modules +RUN chown nextjs:nodejs . + +USER nextjs + +EXPOSE 3000 + +ENV NODE_ENV production + +ENV NEXT_TELEMETRY_DISABLED 1 + +CMD NEXT_PUBLIC_SITE_DOMAIN=$site_domain yarn build && yarn start diff --git a/README.md b/README.md index 0543da0..741fa14 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ The easiest way is to use their creators' own platform, [Vercel](https://vercel. [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2FTheDavidDelta%2Flingva-translate%2Ftree%2Fmain&env=NEXT_PUBLIC_SITE_DOMAIN&envDescription=Your%20domain) +There's also an [official Docker image](https://hub.docker.com/repository/docker/thedaviddelta/lingva-translate) available for easing the deployment using Compose, Kubernetes or similar technologies. Remember to also include the environment variable (simplified to `site_domain`) when running the container. + +```bash +docker run -p 3000:3000 -e site_domain=lingva.ml thedaviddelta/lingva-translate:latest +``` + ## Instances @@ -48,7 +54,6 @@ These are the currently known *Lingva* instances. Feel free to make a Pull Reque | [translate.tixte.gifts](https://translate.tixte.gifts) | [Vercel](https://vercel.com/) | [Let's Encrypt](https://www.ssllabs.com/ssltest/analyze.html?d=translate.tixte.gifts) | - ## Public APIs Nearly all the *Lingva* instances should supply a pair of public developer APIs: a RESTful one and a GraphQL one.